DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: ASP.NET > Image Button HTML result code

  1. #1
    Join Date
    Nov 2005

    ASP.NET > Image Button HTML result code


    I have a weird problem. I am using a a image button code from like this:

    <asp:imagebutton id="bAddAssociacio" runat="server" ImageUrl="Images\remove.gif"></asp:imagebutton>

    Usually the runat="server" tag means that it will automatically have a JS functions, named __dopostback(...), set on a JS event like "onclick" or "onchange" , so actually the HTML code we have in our browser is something like this:
    <INPUT type="button" name="button" id="button" onclick=" __doPostBack('button','')/>"

    The problem is:

    with imagebutton i don't see that code... i just se a html normal image type, with no __doPostBack at all. But the even more weird thing is that it is submitting my petitions to the server as if it was there. So could anyone explain me what's going on.

  2. #2
    Join Date
    May 2005
    There is nothing odd about the behaviour
    Add a HTML button on to your page and place the runat = server attribute for the button , you will see the javascript do post back method etc etc.
    Add a button control and remove your previous control , you will not find the JavaScript
    this is because the ASP.Net architecture uses EventArgument and EventTarget variables for passing event information to the server for its controls, But in the case of Html controls you are promoting the control from a client side control to a server side control , so all the additional work that has to be done is not present in the server, and hence it has to come from your javascript, Recollect that the controls are compiled classes where as Html controls will be interpreted...

    Hope this answers your question

  3. #3
    Join Date
    Nov 2005
    I understand your point, but in fact, ain't in front of my computer right now, but i am not wrong: It does add the "__doPostBack(..)" function on any other ASP.NET web control.

    I will check on that tomorrow but i am almost 99% sure it does. That's why i was surprised to see that asp:imagebutton doesn't add it.

    Tomorrow i will repost about this, thx for the answer btw i appreciate

  4. #4
    Join Date
    Nov 2005
    My bad. You was completly right, i did saw some HTML server controls in the design that i assumed they were asp web controls.

    I appreciate your help, thx.

Similar Threads

  1. Replies: 2
    Last Post: 08-01-2005, 03:12 PM
  2. Generate ASP.Net Forms & Code in minutes
    By Mike Upshon in forum dotnet.announcements
    Replies: 0
    Last Post: 08-16-2002, 05:33 PM
  3. Button image
    By rkbnair in forum ASP.NET
    Replies: 3
    Last Post: 08-01-2001, 10:20 PM
  4. Replies: 90
    Last Post: 04-17-2001, 12:45 AM
  5. Replies: 0
    Last Post: 04-06-2000, 06:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center