I’m trying to do the simplest thing, to show an alert popup through javascript from my code-behind of a user control (ascx.cs).
I’ve tried
protected void btnSave_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(btnSave, GetType(), 'uniqueID', 'alert('hello');', true); }
as well as
Page.ClientScript.RegisterStartupScript(GetType(), 'uniqueID', 'alert('hello');', true);
but nothing seems to work for me. The control is located within an RadAjaxPanel (telerik) in an ASPX page.
I’m missing something obvious here. Any ideas what?
EDIT: The javascript is not injected into the html source as far as I can see. I look for the ID and the actual alert statement in the html.
Ah, the problem was the Telerik RadAjaxPanel. I just had to set the EnableOutsideScripts to true on them, like so:
And then I could use the following code: