Q:Add AutoPostBack flag by Code rather than HTML?

Discussion in 'ASP .Net' started by Sky, Jan 28, 2004.

  1. Sky

    Sky Guest

    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?
    Sky, Jan 28, 2004
    #1
    1. Advertising

  2. Sky

    Natty Gur Guest

    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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Jan 29, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Punya Narra
    Replies:
    5
    Views:
    1,674
    Itai Raz
    Feb 17, 2004
  2. Nehal Shah
    Replies:
    6
    Views:
    731
    Jacob Yang [MSFT]
    Nov 14, 2003
  3. Robin Day
    Replies:
    3
    Views:
    4,444
    Alessandro Zifiglio
    Jan 21, 2004
  4. Replies:
    1
    Views:
    314
  5. mark4asp
    Replies:
    8
    Views:
    6,606
    Andy Dingley
    Mar 17, 2008
Loading...

Share This Page