Thank you very much.
The function you wrote looks perfectly correct to me. However, I'm
getting error "Expected: '{'", and I cannot figure out where it could
be expected.
This is how this function looks in the source:
<input type="submit" name="btnSubmit" value="Submit"
onclick="function() = { if (! dgReport__ctl2_chkConf.checked ||
dgReport__ctl3_chkConf.checked ||dgReport__ctl4_chkConf.checked ||
dgReport__ctl5_chkConf.checked ||dgReport__ctl6_chkConf.checked)
{ return confirm('You have not selected any DRs. Are you sure you want
to submit change?'); } }if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate(); " language="javascript" id="btnSubmit"
class="button" />
Thank you,
Peter
On Mar 20, 6:49 am, "Tom Cole" <tco...@gmail.com> wrote:
> On Mar 19, 9:05 pm, "PeterAfonin" <pafo...@hotmail.com> wrote:
>
>
>
>
>
> > Hello,
>
> > I'm using Javascript in ASP.NET application to check whether at least one
> > checkbox in datagrid has been checked. If validation fails, the user gets a
> > warning. If he clicks OK, the form is submitted, if Cancel - nothing should
> > happen.
>
> > The ASP.NET code looks like this:
>
> > btnSubmit.Attributes.Add("onClick", "if (!(" & sClientSideValidate.ToString
> > & "))" _
> > & "{ confirm('You have not selected any DRs. Are you sure you want to submit
> > change?');return false}")
>
> > All validation is in sClientSideValidate.
>
> > The problem is with "return false". ASP.NET doesn't like the word "return".
> > If I use it - all my ASP.NET validation controls don't work. For instance,
> > if I use "return confirm" - I have a problem, if I use just "confirm" - I
> > have no problem.
>
> > Same with "return false". But in this case I don't know what could I use
> > instead of "return false". I have to use something to cancel form submission
> > if the user clicks "Cancel".
>
> > I'm not an expert in Javascript, so I hope someone could tell me - what
> > could I use instead of "return false" to get the same results?
>
> > I would appreciate your help.
>
> > Thank you,
>
> > --
> >PeterAfonin
>
> First of all your closing brace is not in the proper place, it should
> be before the return statement. But you can do even better than that.
> The confirm box returns the users selection so you can check for true
> or false and return it:
>
> I have no experience with ASP (I'm a JSP developer) but it should look
> something like this:
>
> btnSubmit.Attributes.Add("onclick", "function() = { if (! " &
> sClientSideValidate.ToString & ") { return confirm('You have not
> selected any DRs. Are you sure you want to submit change?'); } }");
>
> HTH.- Hide quoted text -
>
> - Show quoted text -
|