This is a migrated thread and some comments may be shown as answers.

client side and server side button click events

3 Answers 428 Views
Window
This is a migrated thread and some comments may be shown as answers.
cognos s
Top achievements
Rank 1
cognos s asked on 13 Oct 2009, 11:33 AM
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?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Oct 2009, 12:36 PM
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.
0
cognos s
Top achievements
Rank 1
answered on 13 Oct 2009, 12:45 PM
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.
0
cognos s
Top achievements
Rank 1
answered on 13 Oct 2009, 12:47 PM
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
Tags
Window
Asked by
cognos s
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
cognos s
Top achievements
Rank 1
Share this question
or