I have declared a button in my CreateChildControls method in my web part page:

TableCell updateCell = new TableCell();
        Update = new Button();
        Update.Text = "Update";
        Update.OnClientClick += new EventHandler(Update_OnClick);

This is the eventhandler that I created:

    private void Update_OnClick(object sender, EventArgs e)
        if (_TYPE == "FIXED")
            Item["Retail"] = txtFixedRetail.Text;

However JScript throws an error:

Microsoft JScript runtime error: 'System' is undefined

And produces this in the HTML:

<td><input type="submit" name="ctl00$m$g_c260f907_31c1_436b_b99e_9bf79427625c$ctl11"     value="Update" onclick="System.EventHandler;" /></td>

Why is the eventhandler that I declared in the WebPart not passing to the Page? Do I have to push all events to the Client?

1 Answer 1


Button.OnClientClick is assigning JavaScript to run in the browser

Button.Click is for Server side event handling


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.