Forums » .NET » ASP.NET »

Put an asterisk(*)in red color beside a textbox control

Posted Date: 13 Mar 2009      Posted By:: satya     Member Level: Silver    Member Rank: 2835     Points: 1   Responses: 4


I want to put an asterisk(*)in red color beside a textbox control which is mandatory field in a webpage.Can u please tell me how to do that. I will appreciate your help.



#355750    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 13/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2


In aspx page before that textbox add below line.

<em id="mandatory" style="color:Red">*</em>


#355752    Author: Shreekumar      Member Level: Gold      Member Rank: 0     Date: 13/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

Here's the code for .aspx file

< asp:TextBox ID="YourId" runat="server" > < /asp:TextBox >
< span style="color: red" > * < /span >

Shreekumar. S. S
Hobby web developer

Specialized in ASP.Net 2.0, SQL Server 2000, C#, AJAX

#355759    Author: Miss Meetu Choudhary      Member Level: Gold      Member Rank: 14     Date: 13/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2

use the span tag where ever you want to put the red * like

< span style="color: red" > * < /span >

Thanks and Regards
Miss Meetu Choudhary (Site Coordinator)
Go Green Save Green

#355766    Author: Babu Akkandi      Member Level: Gold      Member Rank: 55     Date: 14/Mar/2009   Rating: 2 out of 52 out of 5     Points: 2


this is another way to implement,

place Requirefield validator control next to the each Textbox which are all mantatory,

set following property in Requirefield validator control, thru property window(F4)

errormessage = "*"
controltovalidate = textboxname

when you submit the value, if the value is missed in the text box, then it will display "*" in red color, as you expects.

Hope it Helps!

Note: Plz rate this answer, if it helped you!!

Thanks and Regards,
Babu Akkandi

Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.

Next : How to write the output os response.write at the bottom of the page
Previous : How to validatate a textbox for string in
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India