Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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);
        updateCell.Controls.Add(Update);
        ButtonRow.Controls.Add(updateCell);

This is the eventhandler that I created:

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

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
add comment

1 Answer

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. –  user8746 Jun 14 '12 at 19:03
add comment

Your Answer

 
discard

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.