Click here to Skip to main content
14,387,302 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have two textbox controls and added two required fields validation controls and set the text property of the validation control <img> tag. After that added a button control.
When I click the button without filling anything in the textbox it display images which I have putted in the required field validation control. But I want to display bottom of the button control a text description when any of the required validation is not valid.
I think this can be using if(page.isvalid) then display the text description. But it only work when javascript is disable.
I tried validation summary. This validation control display message like this.

First TextBox is required.

Second TextBox is required.

But I just want to display meaning of the image which I have putted in the text property of the validation control like when any of the textBox is empty then an Image icon is displayed near that textBox and text description bottom of the button control: "Required Fields!"
Posted
Comments
AshishChaudha 28-Jul-12 6:41am
   
What you have tried so far???
Rate this:
Please Sign up or sign in to vote.

Solution 2

Use this

<asp:TextBox ID="txtFirst" runat="server"></asp:TextBox>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1"

        runat="server" ErrorMessage="FirstErrorText" ControlToValidate="txtFirst">
        <img src="Error.png" />       
        </asp:RequiredFieldValidator>

 <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

You can add a label at the bottom of the page and make it visible when Page.IsValid==false.

For Example:
If(Page.IsValid==true)
{
  lblMsg.visible=false;
  <!--your other stuff-->
}
else
{
  lblMsg.visible=true;
  lblMsg.Text="*/Picture Marked Fields are Required!"
}
   
v3
Comments
Dinesh Ambaliya 29-Jul-12 9:19am
   
Thank you for your try.
But as mentioned in my question this only work when javascript is disabled in browser.
pradiprenushe 30-Jul-12 4:04am
   
Use below answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100