Asp.net| Tips
1. Open a new window and transfer parameters:
Transfer parameters:
Response.Write ("<script>window.open
(' *.aspx?id= ' +this.) dropdownlist1.selectindex+ "&id1=" + + "') </script>")
Receive parameters:
String a = Request.QueryString ("id");
String B = Request.QueryString ("Id1");
2. Add a dialog box for the button
BUTTON1.ATTRIBUTES.ADD ("onclick", "return confirm (' Confirm? ')");
Button.attributes.add ("onclick", "If" (Confirm (' Are you sure? '))
{return true;} Else{return false;} ")
3. Delete table Selected records
int intempid = (int) Mydatagrid.datakeys[e.item.itemindex];
String deletecmd = "DELETE from Employee where emp_id =" + intempid.tostring ()
4. Delete the form record warning
private void datagrid_itemcreated (Object Sender,datagriditemeventargs e)
{
Switch (e.item.itemtype)
{
Case ListItemType.Item:
Case ListItemType.AlternatingItem:
Case ListItemType.EditItem:
TableCell Mytablecell;
Mytablecell = e.item.cells[14];
LinkButton Mydeletebutton;
Mydeletebutton = (LinkButton) mytablecell.controls[0];
MyDeleteButton.Attributes.Add
("onclick", "return confirm (' You are sure to delete this message ');");
Break
Default
Break
}
}
5. Click on a table row link another page
private void Grdcustomer_itemdatabound
(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Click on the form to open
if (E.item.itemtype = = ListItemType.Item | |
E.item.itemtype = = ListItemType.AlternatingItem)
E.item.attributes.add ("onclick", "window.open
(' default.aspx?id= "+ e.item.cells[0]. Text + "');
}
Double-click a table to connect to another page, in the ItemDataBind event
if (E.item.itemtype = = ListItemType.Item | |
E.item.itemtype = = ListItemType.AlternatingItem)
{
String Orderitemid =e.item.cells[1]. Text;
E.item.attributes.add ("OnDblClick",
"Location.href=". /shippedgrid.aspx?id= "+ Orderitemid +" "");
}
Double-click a table to open a new page
if (E.item.itemtype = = ListItemType.Item | |
E.item.itemtype = = ListItemType.AlternatingItem)
{
String Orderitemid =e.item.cells[1]. Text;
E.item.attributes.add ("OnDblClick",
"Open ('.. /shippedgrid.aspx?id= "+ Orderitemid +" ")";
}
★ Special attention: "? id=" Can not be "? id ="
[1] [2] [3] [4] [5] Next page