I faced a 'problem' while needed to add a postback event to the server while generating client code from the server on runtime.
You could think about a way of creating server control in the code behind and attaching it an event to its OnClick (or other event), but this one is good enough only to server controls that knows to do postback.
What will you do if you'll want to add postback event to a generic client control such as html-table-cell of other client controls that doesn't need to contact the server beside the postback event?
The GetPostBackEventReference method of the Page object's ClientScript property supports this action and let you perform this action. By MSDN property summary, this one "Returns a string that can be used in a client event to cause postback to the server. The reference string is defined by the specified control that handles the postback and a string argument of additional event information".
// ...TableCell tc = new TableCell();// Add some attributes or styling...tc.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, <argument>));// Do you stuff (add the cell to the table) etc.
Remember Me
Page rendered at 8/20/2008 12:49:22 PM (Jerusalem Standard Time, UTC+02:00) Theme Design by Aaron Yuen
Powered by: newtelligence dasBlog 1.8.5223.2
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2008, Eran Nachum
E-mail