Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
1.22/5 (2 votes)
Hi,


from code-behind am calling a script function in button click event as
C#
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "overlay('Saved Succesfully ')", true);

from default.aspx page is running good and assigning "saved successfully: text to the label but when i load a page by passing query string as default.aspx?id=98 it is the popup is loading but the value is not assigned to label i.e,"saved successfully" text is not passing to the script function can any one suggest me how to solve this and this is the function am calling
XML
function overlay(value) {
                  
                   el = document.getElementById('ovrly');
                   $('#ovrly').show();

                   $('#<%= pbl.ClientID %>').text(value);

               }
Posted
Comments
Sergey Alexandrovich Kryukov 18-Aug-14 13:17pm    
You never even really call Javascript from code behind. You generate script or register the script, which is, essentially, still generating the script in the HTTP response. The script is called in a browser, nowhere else.
—SA

just missed the semicolon I think.

C#
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "overlay('Saved Succesfully ');", true);


or

C#
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>disp_confirm();</script>", false);
 
Share this answer
 
v2
Use below code in C# where abc is your Javascript function.

ScriptManager.RegisterStartupScript(this, GetType(), "importingdone", "abc();", true);
 
Share this answer
 
Below code work for me, so you can give a try

ClientScript.RegisterClientScriptBlock(this.GetType(), "XYZ", "XYZ();", true);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900