client side and server side button click events

4 posts, 0 answers
  1. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 13 Oct 2009 Link to this post

    I am loading user controls dynamically while using tabstrip. On one of the tab user control I have save button.

    <

     

    asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="return validate();" onclick="btnSave_Click" />
    the javascript function is written in external .js file.

    In one scenario, if the javscript validations pass, I want the server side click event to execute and open radwindow on server side using the below code. But the server side event is not executing. if I take out onClientClick event then only server side event is firing. Also the  radalert doesnt pop out.

     

    string

     

    openWindow = "<script language='javascript'>function f(){var navUrl = 'http://www.telerik.com';var oWindow = radopen(navUrl);oWindow.set_width(300);oWindow.set_height(300);oWindow.center();Sys.Application.remove_load(f);};Sys.Application.add_load(f);</script>";

     

    Page.ClientScript.RegisterStartupScript(

    this.GetType(), "radalert", openWindow);

    here is the validate function in javascript file:

    function validate()

     

    if

     

    (!rdChecked) {

     

        radalert('Validation failed

    ', 300, 100, '');

     

     

    return false;

     

    }

    else {

     

     

     

    return true;

     

    }

     


    any ideas?

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Oct 2009 Link to this post

    Hi Cognos,

    I have gone through your code. I guess the rdChecked variable value is false every time and thereby the clientside event returns false and server event is cancelled. Check the value of rdChecked and see whether it returns correct value as you expected.

    Checkout the following KB Article which shows how to call radalert from code behind.
    Calling radalert from codebehind (all versions of RadWindow)

    -Shinu.
  3. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 13 Oct 2009 Link to this post

    rdChecked is not false all the time..if the radiobutton is checked then it returns true value...I debugged through javascript and its returing true value if its checked.

    Actually I have the same user control on a page and the events are working fine. When I integrate it with the tabstrip I come across this issue.
  4. cognos s
    cognos s avatar
    35 posts
    Member since:
    Oct 2009

    Posted 13 Oct 2009 Link to this post

    Initially I had the javascript for the usercontrol in the user control html file. But I had to move it to an external .js file. Do you think the issue is because of external .js file
Back to Top