asp.net development of common skills collection

Source: Internet
Author: User
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.