Common codes for asp.net Development

Source: Internet
Author: User

// Repeater item binding event
Protected void rptCategory_ItemDataBound (object sender, RepeaterItemEventArgs e)
{
If (e. Item. ItemType = ListItemType. AlternatingItem | e. Item. ItemType = ListItemType. Item)
{
}
}

// Pop-up
Page. ClientScript. RegisterStartupScript (Page. ClientScript. GetType (), "myscript", "alert ('user has no permission! '); ", True );

// Ajax pop-up
ScriptManager. RegisterClientScriptBlock (upCatalog, typeof (UpdatePanel), "myscript", "alert ('enter the number! '); ", True );


// Confirmation box
OnClientClick = "return confirm ('Are you sure you want to delete this shipping address? ')"

// Email Verification

<Asp: regularExpressionValidator ID = "refUserNameOrEmail" runat = "server" ControlToValidate = "UserName" Display = "Dynamic" ErrorMessage = "Invalid email" ToolTip = "Invalid email" ValidationExpression = "[\ w \. -] + (\ + [\ w-] *)? @ ([\ W-] + \.) + [\ w-] +"
ValidationGroup = "CreateUserForm"> incorrect E-mail format </asp: RegularExpressionValidator>


// Only numbers can be entered
<Asp: TextBox runat = "server" ID = "txtMobileNumber" CssClass = "adminInput" onkeyup = "value = value. replace (/[^ \ d]/g, '');" onbeforepaste = "clipboardData. setData ('text', clipboardData. getData ('text '). replace (/[^ \ d]/g, '')"> </asp: TextBox>

// Only Chinese characters can be entered
<Asp: TextBox ID = "txtLastName" runat = "server" MaxLength = "40" onkeyup = "value = value. replace (/[^ \ u4E00-\ u9FA5]/g, '')" onbeforepaste = "clipboardData. setData ('text', clipboardData. getData ('text '). replace (/[^ \ u4E00-\ u9FA5]/g, '')"> </asp: TextBox>


// Mobile phone Verification
<Asp: RegularExpressionValidator runat = "server" ID = "RegularExpressionValidator1" Display = "Dynamic" ControlToValidate = "txtMobileNumber" ErrorMessage = 'example: 100'
ToolTip = 'invalidemail 'ValidationGroup = "CustomerInfo" ValidationExpression = "^ (\ d {3} \) | (\ d {3 }\-))? 13 [0-9] \ d {8} | 15 [0-9] \ d {8} | 18 [0-9] \ d {8 }) "> </asp: RegularExpressionValidator>

Add serial number
<% # Container. ItemIndex + 1%>
<% # Container. DataItemIndex + 1%>


Author: "libt's column libt"

Related Article

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.