none
Anchor Tag Validation

    Question

  • Hi,

    I have the  following Anchor Tag in c# code

    String.Format("<li><a id=\"lnk{0}\" href=\"javascript:OpenTaskDialog('{2}')\" runat=\"server\" onclick=\"javascript:ValidateRadioButton();\">{1}</a></li>", ct.Id.ToString(), ct.Name, url));
    

    What I need is , open Dialog only when the validation function returns true.

    how can i do that?

    thanks

    Azra

    Tuesday, January 17, 2012 12:46 PM

Answers

  • Hi Azra,

    What you need to do is just let the <a/> link act as a real anchor, to set the value of href property to "#". and choose to execute the OpenTaskDialog function or not according to the true/false result in the function body of ValidateRadioButton function.

    Have a nice day, 

    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 23, 2012 9:55 AM
    Moderator

All replies

  • Hi Azra,

    What you need to do is just let the <a/> link act as a real anchor, to set the value of href property to "#". and choose to execute the OpenTaskDialog function or not according to the true/false result in the function body of ValidateRadioButton function.

    Have a nice day, 

    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 23, 2012 9:55 AM
    Moderator
  • Page_ClientValidate() will work. It returns true if the page was valid and it works fine.

    If you are using ASP.NET 2.0, pass the validation group name as a parameter. e.g.

    if(Page_ClientValidate("YourValidationGroupName"))
         alert
    ('it is valid');

    otherwise if there is no validation group Page_ClientValidate("") will handle it. e.g.

    if(Page_ClientValidate(""))
         alert
    ('it is valid');
    Monday, February 13, 2012 5:57 AM