How to validate a textbox for range of values,correct date?

How to validate a textbox for range of values,correct date?

In scenarios where we want to validate a textbox for the specific range of values, and ensure that the correct Date to be entered, we can follow this approach.

Validations
Validation controls are used to validate the form fields for valid data when it is submitted to the server.
  • In case we want to validate a textbox for the specific range of values to be entered, we can follow this approach.
ASPX PAGE 

Enter year between 2000 to 2010:
<asp:TextBox ID="txtRange" runat="server" /><br />
<asp:RangeValidator ID="range1" runat="server" ErrorMessage="Sorry, must be
between 2000 and 2010" ControlToValidate="txtRange" MaximumValue="2010" MinimumValue="2000"
Type="Integer" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 

In the above code snippet, we have a TextBox that must accept the value in between 2000 and 2010. To validate this range, we can use asp:RangeValidator with MaximumValue as 2010 and MinimumValue as 2000 with Type as “Integer”. This causes the TextBox to accept only values in between 2000 to 2010.
Note: The asp:RangeValitor only works if any data is entered to the TextBox, if no data is entered and button is clicked the form is submitted to the server without validation. To avoid this, we should keep asp:RequiredFieldValidator attached with the TextBox to validate.


Note: Similarly Date, Double, String, Currency values can be validated for specific range.

  • In case we want to validate a textbox value for the correct date, we can follow this approach.

ASPX PAGE

 

Date of birth:
<asp:TextBox ID="txtDOB" runat="server" /><br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtDOB"
ForeColor="Red" />
<asp:CompareValidator ID="comp1" runat="server" ErrorMessage="Date must be in
MM/DD/YYYY format" ControlToValidate="txtDOB" Type="Date" Operator="DataTypeCheck" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 


In the above code snippet, we have a TextBox that must accept correct date. To do that we can use asp:CompareValidator with Operator as “DataTypeCheck” and Type as “Date”. We have used asp:RequiredFieldValidator to force user to enter some data into the TextBox before the form is submitted to the server.


  • In scenarios where we want to check whether a valid email id has been entered into the TextBox or not, we can follow this approach.

ASPX PAGE

 

Your email:
<asp:TextBox ID="txtEmail" runat="server" Columns="50" />
<br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtEmail"
ForeColor="Red" />
<asp:RegularExpressionValidator ID="ReExp1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="eg. abc@domain.com" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SubmitData" />
</p> 


CODE BEHIND
 
protected void SubmitData(object sender, EventArgs e)
{

}


In the above code snippet, we want to validate the TextBox for correct format of the email id. For that we have used asp:RegularExpressionValidator with ValidationExpression as “\w+([-+.']\w+)*@\w+([- .]\w+)*\.\w+([-.]\w+)*” that validates the TextBox data for correct email id format (eg. abc@domain.com).
We have used asp:RequiredFieldValidtor to force user to enter some data into the TextBox.

Hope this Post was useful. Thanks for reading.

Keep reading my forth coming Post s. To read my series of articles on ASP.NET,





How to validate a textbox for range of values,correct date?

In scenarios where we want to validate a textbox for the specific range of values, and ensure that the correct Date to be entered, we can follow this approach.

Validations
Validation controls are used to validate the form fields for valid data when it is submitted to the server.
  • In case we want to validate a textbox for the specific range of values to be entered, we can follow this approach.
ASPX PAGE 

Enter year between 2000 to 2010:
<asp:TextBox ID="txtRange" runat="server" /><br />
<asp:RangeValidator ID="range1" runat="server" ErrorMessage="Sorry, must be
between 2000 and 2010" ControlToValidate="txtRange" MaximumValue="2010" MinimumValue="2000"
Type="Integer" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 

In the above code snippet, we have a TextBox that must accept the value in between 2000 and 2010. To validate this range, we can use asp:RangeValidator with MaximumValue as 2010 and MinimumValue as 2000 with Type as “Integer”. This causes the TextBox to accept only values in between 2000 to 2010.
Note: The asp:RangeValitor only works if any data is entered to the TextBox, if no data is entered and button is clicked the form is submitted to the server without validation. To avoid this, we should keep asp:RequiredFieldValidator attached with the TextBox to validate.


Note: Similarly Date, Double, String, Currency values can be validated for specific range.

  • In case we want to validate a textbox value for the correct date, we can follow this approach.

ASPX PAGE

 

Date of birth:
<asp:TextBox ID="txtDOB" runat="server" /><br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtDOB"
ForeColor="Red" />
<asp:CompareValidator ID="comp1" runat="server" ErrorMessage="Date must be in
MM/DD/YYYY format" ControlToValidate="txtDOB" Type="Date" Operator="DataTypeCheck" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 


In the above code snippet, we have a TextBox that must accept correct date. To do that we can use asp:CompareValidator with Operator as “DataTypeCheck” and Type as “Date”. We have used asp:RequiredFieldValidator to force user to enter some data into the TextBox before the form is submitted to the server.


  • In scenarios where we want to check whether a valid email id has been entered into the TextBox or not, we can follow this approach.

ASPX PAGE

 

Your email:
<asp:TextBox ID="txtEmail" runat="server" Columns="50" />
<br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtEmail"
ForeColor="Red" />
<asp:RegularExpressionValidator ID="ReExp1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="eg. abc@domain.com" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SubmitData" />
</p> 


CODE BEHIND
 
protected void SubmitData(object sender, EventArgs e)
{

}


In the above code snippet, we want to validate the TextBox for correct format of the email id. For that we have used asp:RegularExpressionValidator with ValidationExpression as “\w+([-+.']\w+)*@\w+([- .]\w+)*\.\w+([-.]\w+)*” that validates the TextBox data for correct email id format (eg. abc@domain.com).
We have used asp:RequiredFieldValidtor to force user to enter some data into the TextBox.

Hope this Post was useful. Thanks for reading.

Keep reading my forth coming Post s. To read my series of articles on ASP.NET,





How to validate a textbox for range of values,correct date?

How to validate a textbox for range of values,correct date?

In scenarios where we want to validate a textbox for the specific range of values, and ensure that the correct Date to be entered, we can follow this approach.

Validations
Validation controls are used to validate the form fields for valid data when it is submitted to the server.
  • In case we want to validate a textbox for the specific range of values to be entered, we can follow this approach.
ASPX PAGE 

Enter year between 2000 to 2010:
<asp:TextBox ID="txtRange" runat="server" /><br />
<asp:RangeValidator ID="range1" runat="server" ErrorMessage="Sorry, must be
between 2000 and 2010" ControlToValidate="txtRange" MaximumValue="2010" MinimumValue="2000"
Type="Integer" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 

In the above code snippet, we have a TextBox that must accept the value in between 2000 and 2010. To validate this range, we can use asp:RangeValidator with MaximumValue as 2010 and MinimumValue as 2000 with Type as “Integer”. This causes the TextBox to accept only values in between 2000 to 2010.
Note: The asp:RangeValitor only works if any data is entered to the TextBox, if no data is entered and button is clicked the form is submitted to the server without validation. To avoid this, we should keep asp:RequiredFieldValidator attached with the TextBox to validate.


Note: Similarly Date, Double, String, Currency values can be validated for specific range.

  • In case we want to validate a textbox value for the correct date, we can follow this approach.

ASPX PAGE

 

Date of birth:
<asp:TextBox ID="txtDOB" runat="server" /><br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtDOB"
ForeColor="Red" />
<asp:CompareValidator ID="comp1" runat="server" ErrorMessage="Date must be in
MM/DD/YYYY format" ControlToValidate="txtDOB" Type="Date" Operator="DataTypeCheck" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 


In the above code snippet, we have a TextBox that must accept correct date. To do that we can use asp:CompareValidator with Operator as “DataTypeCheck” and Type as “Date”. We have used asp:RequiredFieldValidator to force user to enter some data into the TextBox before the form is submitted to the server.


  • In scenarios where we want to check whether a valid email id has been entered into the TextBox or not, we can follow this approach.

ASPX PAGE

 

Your email:
<asp:TextBox ID="txtEmail" runat="server" Columns="50" />
<br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtEmail"
ForeColor="Red" />
<asp:RegularExpressionValidator ID="ReExp1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="eg. abc@domain.com" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SubmitData" />
</p> 


CODE BEHIND
 
protected void SubmitData(object sender, EventArgs e)
{

}


In the above code snippet, we want to validate the TextBox for correct format of the email id. For that we have used asp:RegularExpressionValidator with ValidationExpression as “\w+([-+.']\w+)*@\w+([- .]\w+)*\.\w+([-.]\w+)*” that validates the TextBox data for correct email id format (eg. abc@domain.com).
We have used asp:RequiredFieldValidtor to force user to enter some data into the TextBox.

Hope this Post was useful. Thanks for reading.

Keep reading my forth coming Post s. To read my series of articles on ASP.NET,





How to validate a textbox for range of values,correct date?

In scenarios where we want to validate a textbox for the specific range of values, and ensure that the correct Date to be entered, we can follow this approach.

Validations
Validation controls are used to validate the form fields for valid data when it is submitted to the server.
  • In case we want to validate a textbox for the specific range of values to be entered, we can follow this approach.
ASPX PAGE 

Enter year between 2000 to 2010:
<asp:TextBox ID="txtRange" runat="server" /><br />
<asp:RangeValidator ID="range1" runat="server" ErrorMessage="Sorry, must be
between 2000 and 2010" ControlToValidate="txtRange" MaximumValue="2010" MinimumValue="2000"
Type="Integer" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 

In the above code snippet, we have a TextBox that must accept the value in between 2000 and 2010. To validate this range, we can use asp:RangeValidator with MaximumValue as 2010 and MinimumValue as 2000 with Type as “Integer”. This causes the TextBox to accept only values in between 2000 to 2010.
Note: The asp:RangeValitor only works if any data is entered to the TextBox, if no data is entered and button is clicked the form is submitted to the server without validation. To avoid this, we should keep asp:RequiredFieldValidator attached with the TextBox to validate.


Note: Similarly Date, Double, String, Currency values can be validated for specific range.

  • In case we want to validate a textbox value for the correct date, we can follow this approach.

ASPX PAGE

 

Date of birth:
<asp:TextBox ID="txtDOB" runat="server" /><br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtDOB"
ForeColor="Red" />
<asp:CompareValidator ID="comp1" runat="server" ErrorMessage="Date must be in
MM/DD/YYYY format" ControlToValidate="txtDOB" Type="Date" Operator="DataTypeCheck" ForeColor="Red" />
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</p> 


In the above code snippet, we have a TextBox that must accept correct date. To do that we can use asp:CompareValidator with Operator as “DataTypeCheck” and Type as “Date”. We have used asp:RequiredFieldValidator to force user to enter some data into the TextBox before the form is submitted to the server.


  • In scenarios where we want to check whether a valid email id has been entered into the TextBox or not, we can follow this approach.

ASPX PAGE

 

Your email:
<asp:TextBox ID="txtEmail" runat="server" Columns="50" />
<br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Mandatory !" ControlToValidate="txtEmail"
ForeColor="Red" />
<asp:RegularExpressionValidator ID="ReExp1" runat="server" ControlToValidate="txtEmail"
ErrorMessage="eg. abc@domain.com" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-
.]\w+)*"></asp:RegularExpressionValidator>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SubmitData" />
</p> 


CODE BEHIND
 
protected void SubmitData(object sender, EventArgs e)
{

}


In the above code snippet, we want to validate the TextBox for correct format of the email id. For that we have used asp:RegularExpressionValidator with ValidationExpression as “\w+([-+.']\w+)*@\w+([- .]\w+)*\.\w+([-.]\w+)*” that validates the TextBox data for correct email id format (eg. abc@domain.com).
We have used asp:RequiredFieldValidtor to force user to enter some data into the TextBox.

Hope this Post was useful. Thanks for reading.

Keep reading my forth coming Post s. To read my series of articles on ASP.NET,





Are all the below border styles valid :-

Are all the below border styles valid :- 

border-style: inset; 
border-style: outset; 
border-style: double; 
border-style: dotted; 
border-style: dashed; 
border-style: solid; 
border-style: none; 
border-style: groove; 
border-style: ridge; 
border-style: hidden;

 

Ans)

Yes, all the above mentioned border styles are valid.

Are all the below border styles valid :- 

border-style: inset; 
border-style: outset; 
border-style: double; 
border-style: dotted; 
border-style: dashed; 
border-style: solid; 
border-style: none; 
border-style: groove; 
border-style: ridge; 
border-style: hidden;

 

Ans)

Yes, all the above mentioned border styles are valid.

Are all the below border styles valid :-

Are all the below border styles valid :- 

border-style: inset; 
border-style: outset; 
border-style: double; 
border-style: dotted; 
border-style: dashed; 
border-style: solid; 
border-style: none; 
border-style: groove; 
border-style: ridge; 
border-style: hidden;

 

Ans)

Yes, all the above mentioned border styles are valid.

Are all the below border styles valid :- 

border-style: inset; 
border-style: outset; 
border-style: double; 
border-style: dotted; 
border-style: dashed; 
border-style: solid; 
border-style: none; 
border-style: groove; 
border-style: ridge; 
border-style: hidden;

 

Ans)

Yes, all the above mentioned border styles are valid.

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

Ans)

 

• Content page PreInit event. 
• Master page controls Init event. 
• Content controls Init event. 
• Master page Init event. 
• Content page Init event. 
• Content page Load event. 
• Master page Load event. 
• Master page controls Load event. 
• Content page controls Load event. 
• Content page PreRender event. 
• Master page PreRender event. 
• Master page controls PreRender event. 
• Content page controls PreRender event. 
• Master page controls Unload event. 
• Content page controls Unload event. 
• Master page Unload event. 
• Content page Unload event

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

Ans)

 

• Content page PreInit event. 
• Master page controls Init event. 
• Content controls Init event. 
• Master page Init event. 
• Content page Init event. 
• Content page Load event. 
• Master page Load event. 
• Master page controls Load event. 
• Content page controls Load event. 
• Content page PreRender event. 
• Master page PreRender event. 
• Master page controls PreRender event. 
• Content page controls PreRender event. 
• Master page controls Unload event. 
• Content page controls Unload event. 
• Master page Unload event. 
• Content page Unload event

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

Ans)

 

• Content page PreInit event. 
• Master page controls Init event. 
• Content controls Init event. 
• Master page Init event. 
• Content page Init event. 
• Content page Load event. 
• Master page Load event. 
• Master page controls Load event. 
• Content page controls Load event. 
• Content page PreRender event. 
• Master page PreRender event. 
• Master page controls PreRender event. 
• Content page controls PreRender event. 
• Master page controls Unload event. 
• Content page controls Unload event. 
• Master page Unload event. 
• Content page Unload event

If Master Page is attached with a child, which event's will be fired first. Explain the execution of page?

Ans)

 

• Content page PreInit event. 
• Master page controls Init event. 
• Content controls Init event. 
• Master page Init event. 
• Content page Init event. 
• Content page Load event. 
• Master page Load event. 
• Master page controls Load event. 
• Content page controls Load event. 
• Content page PreRender event. 
• Master page PreRender event. 
• Master page controls PreRender event. 
• Content page controls PreRender event. 
• Master page controls Unload event. 
• Content page controls Unload event. 
• Master page Unload event. 
• Content page Unload event

difference between Early Binding and Late Binding?

difference between Early Binding and Late Binding?
Ans)
Early Binding: 
Compiler bind the objects to methods at the compile time.This is called early binding or static binding.Function overloading is example for early binding. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes. For example, the following code fragment declares a variable to be of type 

Example 

' Add Imports statements to the top of your file.
Imports System.IO

'...

'  Create a variable to hold a new object.

   Dim FS As FileStream

  ' Assign a new object to the variable.

   FS = New FileStream("C:\tmp.txt", FileMode.Open)


Late Binding: 

Compiler bind the objects to methods at the runtime.This is called late binding or dynamic binding.Function overriding is example for late binding. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.
difference between Early Binding and Late Binding?
Ans)
Early Binding: 
Compiler bind the objects to methods at the compile time.This is called early binding or static binding.Function overloading is example for early binding. Early bound objects allow the compiler to allocate memory and perform other optimizations before an application executes. For example, the following code fragment declares a variable to be of type 

Example 

' Add Imports statements to the top of your file.
Imports System.IO

'...

'  Create a variable to hold a new object.

   Dim FS As FileStream

  ' Assign a new object to the variable.

   FS = New FileStream("C:\tmp.txt", FileMode.Open)


Late Binding: 

Compiler bind the objects to methods at the runtime.This is called late binding or dynamic binding.Function overriding is example for late binding. Objects of this type can hold references to any object, but lack many of the advantages of early-bound objects.