views:

411

answers:

1

Hello,

I read tis post

but my problem still there. I try to execute a javascript multiple time on post back, and the script only execute the first time the page load.

To make sure the script is register after each post back i use a guid for the javascript key name.

var xyz = DateTime.Now.ToLongTimeString();
  string script = @"BrokerCustomValue.value='" + CustomValueToBrokerListSerialized + "';alert('" + xyz + "');";
  ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), script, true);

I need to precise that my post back event fire after a click on a link button in an update panel. If i put my link butto directly in the page it's working

+1  A: 

I found the solutions.

When you use an update panel and whant register script, you need to user updatePanel, and updatepanel type in param of the registerstartupscript

like this :

var xyz = DateTime.Now.ToLongTimeString();
  string script = @"BrokerCustomValue.value='" + CustomValueToBrokerListSerialized + "';alert('" + xyz + "');";
  ScriptManager.RegisterStartupScript(_updPanel, _updPanel.GetType(), Guid.NewGuid().ToString(), script, true);
Cédric Boivin