Setting value for javascript variable from code behind (C#) -


i understand difference between client-side , server-side scripting. have javascript function , variable in masterpage:

<script language="javascript" type="text/javascript">     var needtoconfirm = false;           window.onbeforeunload = confirmexit;           function confirmexit()           {             if (needtoconfirm)             {               needtoconfirm = false;               return "currently in edit mode. if leave page lose unsaved changes."             }           } </script> 

given fact on asp.net (client-side) can change value of needtoconfirm variable true onclientclick default false. here's example.

 <asp:button id="btnedit" runat="server" text="  edit  " onclick="btnedit_click" onclientclick="needtoconfirm = true;" /> 

now question here when on c# (server-side) have set needtoconfirm true under if-statement not on page_load:

private void setdefault()      if (session[def.id_cust] != null)     {           //i want change variable value here     } } 

thanks.

update

i'm using .net 2.0 classic , webforms

in code behind:

scriptmanager.registerstartupscript(this, this.gettype(), "", "urfunction('urvalhere');", true); 

on client-side:

function urfunction(urparam) {         //do u want here         //use urparam     } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -