Q:Add AutoPostBack flag by Code rather than HTML?

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?
 
N

Natty Gur

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top