SCENARIO I have page that was hosted inside the iframe and I want to redirect the parent window when a user click a button inside the child page. For that I added the following code in the Button’s click event as I have to execute some server side code before redirecting. Page.ClientScript.RegisterS... RedirectKey, string.Format("window.top.l... = ‘http://google.com’;", url), true); PROBLEM Above mentioned code worked great but when the user used the browser’s back ......
To pass the additional parameter to the event function pass an array of key value, as the second parameter to the bind event bind('click', { message: time }, onClick); e.g { message: time } and access it in the function using event<function parameter>.data.message&... <div id="div1" style="border: 1px solid black; width: 100px; height: 100px">click me</div> <script type="text/javascript"> function onClick(event) { alert(event.data.message); } var time = "loaded at:" ......
I developed a custom control that utilizing client side functionality also. What I needed is calling client side function on clicking button.
to accomplish this we need to find the clientside object for that we use $find passing clientId of the custom web control as mentioned below.
btn.OnClientClick = string.Format("$find('{0}').add({1});", this.ClientID, ‘add’);
1. Set EnableScriptGlobalization=true on the script manager <asp:ScriptManager runat="server" EnableScriptGlobalization="... /> 2. Use the Sys.CultureInfo.CurrentCulture command either inside the alert or through Firebug console to check the CultureInfo at the client side 3. use Number.parseLocale instead of pareFloat so that it get correct value according to the current culture. 4. to update the value back with current culture use localeFormat <script type="text/javascript"> function ......
Add add_endRequest handler to the Page request manager as followed
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(<javascript name function>);
call the parent javascript function using parent.
parent.update();
where update() is the name of the fuction that exist on the page that host the iframe.
calling __doPostBack method with updatePanel’s client id.
function updateUpdatePanel()
{
__doPostBack('<%=updatePanel.ClientID %>', '');
}