Q:Add AutoPostBack flag by Code rather than HTML?

  • Thread starter Thread starter Sky
  • Start date Start date
S

Sky

Hello:

If I want to conver the following HTML code to be created dynamically in a
Render() event, how do I pull off setting the AutoPostBack Flag?


<asp:imagebutton runat="server" id='ID_EditBtn' OnClick="OnClick_EditMe"
style='width:16px;height:16px;margin:0;padding:0;margin-left:4px;border:0;'
/>



What I have so far is:


oImg = new System.Web.UI.WebControls.ImageButton();

oImg.ID = "ID_ExpandBtn";

oImg.Click += OnClick_ExpandMe;

oImg.Attributes.Add("style","width:16px;height:16px;margin:0;padding:0;margi
n-left:4px;border:0;");

//oImg.AutoPostBack = ???



Thanks!

Sky



PS: Is that the correct way to wire up the OnClick_ExpandMe?

PPS: Is that the preferred way of setting "style"? Or is that wrong too?
 
Hi again,

1) Command controls (Button,imagebutton, etc) don't have autopostback
due to their nature to cause postback every time they press / click.

2) No, you should use delegate :
o.Click += new System.Web.UI.ImageClickEventHandler (Func);

where Func match ImageClickEventHandler delegate.

3) Yes.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top