C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Dynamic controls with Validation


Posted Date: 03 Jul 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: UltimateRenganMember Level: Diamond    
Rating: 1 out of 5Points: 10



Dynamic controls with validation.
Here we can create the Dynamic Textbox control and RegularExpressionvalidator.
The RegularExpression "control to validate" property assing to Textbox control.
The RegularExpression Error Message will display when we give wrong values to Textbox.
Bind the Dynamic control to form with help of Form or placeholder or panel control.Here used form for bind the controls to form.


Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Req As New RegularExpressionValidator
Dim txtname As TextBox
txtname = New TextBox
txtname.ID = "txtName"
form1.Controls.Add(txtname)

Dim lblName As Label
lblName = New Label
lblName.Text = "Enter Name"
Req.ControlToValidate = "txtName"
Req.ErrorMessage = "Enter only Numbers"
Req.ValidationExpression = "[0-9]*"
Req.SetFocusOnError = True
form1.Controls.Add(Req)
End Sub

End Class




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Dynamic controls with Validation  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Bind Textbox values to Datalist
Previous Resource: How to add Sitemap to Treeview control
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use