C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




validator


Posted Date: 30 Aug 2008      Total Responses: 1

Posted By: amresh chandra       Member Level: Silver     Points: 1


I have a required field validator with control to validate to textbox1.text.
Now i have a problem whenever a required field validator sown on page(when error) its correspondanse textfield backcolor must be changed




Responses

Author: ramana    30 Aug 2008Member Level: BronzeRating:     Points: 6
CustomValidator is suitable for u r requirement.Below code is useful to u.
.aspx:
<form id="form1" runat="server">
<div>
<asp:TextBox id="txtProductCode" Runat="server" />
<asp:CustomValidator id="valProductCode" ControlToValidate="txtProductCode" Text="(Invalid product code)" OnServerValidate="valProductCode_ServerValidate" Runat="server" ValidateEmptyText="true"/>
<asp:Button id="btnSubmit" Text="Submit" Runat="server" OnClick="btnSubmit_Click" />
</div>
</form>
.aspx.cs:
public void valProductCode_ServerValidate(object source, ServerValidateEventArgs args)
{
if (args.Value.Length > 0)
{
args.IsValid = true;
}
else
{
txtProductCode.BackColor = System.Drawing.Color.Yellow;
args.IsValid = false;
}
}



Post Reply
You must Sign In to post a response.
Next : View state not retaining dropdownlist value
Previous : its very urgent......please help me...
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use