validation group problem

P

Puja

hi all,

am using .net version 2.0 with c#

I have a textbox , required field validator and a button in my code. Code is
below
<div id="divComplete" style="padding-left: 10px;">

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

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1"

ErrorMessage="RequiredFieldValidator"
ValidationGroup="grpTest"></asp:RequiredFieldValidator>

<asp:Button ID="Button1" runat="server" Text="Process"
OnClientClick="javascript:ShowProgress();" ValidationGroup="grpTest"
OnClick="Button1_Click" /> </div>



<div id="divProgress" style="display: none">

<table border="0" cellpadding="0" cellspacing="0" class="steps_border"
width="100%">

<tr> <td colspan="3" align="left" valign="top" class="content_header"> <br
/> Please wait while we process your request ......... </td> </tr>

</table> </div>

and following is my javascript funtion

<script type="text/javascript">

function ShowProgress() {

document.getElementById('divComplete').style.display = 'none';
document.getElementById('divProgress').style.display = 'block'; }

</script>

Now my problem is when i hit button "Process" without filling in the
textbox, ShowProgress function gets executed and required field validation
is not raised.

if I take out OnClientClick="javascript:ShowProgress();" then validation is
raised as normal and it works fine.

Does anybody know how can I raise validation before executing
OnClientClick="javascript:ShowProgress();" function ??

Please help

thanks

puja
 
S

Sachin Hingole

Hi Puja,

You can solve this problem by assigning the javascript click event from the code behind it will work fine

btnID.Attributes.Add("onclick","ShowProgress();");

Thanks
Hingole Sachin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top