SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

Button.OnClientClick is assigning JavaScript to run in the browser

Button.Click is for Server side event handling

share|improve this answer
Thank you. You are always very helpful. – Walter Johnson Jun 14 '12 at 19:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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