Riddle me this, SO. I have two buttons:
<div class="btn-group" role="group">
<asp:Button runat="server" ID="RegisterButton" ClientIDMode="Static" OnClick="RegisterButton_Click" Text="register" />
<asp:Button runat="server" ID="TestButton" ClientIDMode="Static" OnClick="TestButton_Click" Text="testClick" />
</div>
Which call two different functions:
protected void RegisterButton_Click(object sender, EventArgs e)
{
...
Register(user)
}
private void Register (user)
{
...
RegisterResultResultJson(regRes);
}
private void RegisterResultResultJson(RegResult regResult)
{
string jsonString = Helpers.Serializer.JsonSerializer.ToJSON(regResult);
string script = ";RegisterResult(" + jsonString + ");";
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "RegisterStartupScript", script, true);
}
protected void TestButton_Click(object sender, EventArgs e)
{
string script = ";console.log('klik');";
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "RegisterStartupScript", script, true);
}
When I click TestButton, everything works as expected, I can see script in source and console logs "klik". But when I click RegisterButton nothing happens. When I put breakpoint into code, copy script and paste it into console, JS RegisterResult() works properly.