Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Strange issue with ImageButton with no ImageUrl

Reply
Thread Tools

Strange issue with ImageButton with no ImageUrl

 
 
Gary K
Guest
Posts: n/a
 
      01-08-2008
I realize that there is no good reason for an image button to not have an
ImageUrl but I have just hit upon a strange problem when converting an
ASP.NET 1.1 web application to 2.0. An asp:ImageButton control without an
ImageUrl contained within a WebForm causes a redirect to the default
document in IIS. This behaviour did not occur in .NET 1.1.

This can easily be duplicated by the following steps :-

1. Create a new ASP.NET Web Application project in VS2005.
2. Add a new Web Form (WebForm1.aspx)
3. In the existing Default.aspx add a standard asp:Button to the form and
add a standard on click event handler containing a simple
Response.Redirect("WebForm1.aspx");
4. Add an asp:ImageButton to WebForm1.aspx, e.g <asp:ImageButton
ID="ImageButton1" runat="server" />
5. Set two breakpoints, one on each Page_Load method of both Web Forms.

Debug the application, you will notice it breakpoints on the Default.aspx
page load and on the postback when you press the button. This is fine. It
will then breakpoint on the page load of WebForm1.aspx and *THEN* redirect
back to Default.aspx and break on the page load event again. The final
breakpoint does not occur if the ImageUrl is completed or if no default
document has been setup in IIS.

Thanks

Gary


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      01-08-2008
this is standard browser behavior. any img, script, css, etc, with a src=""
or missing, will use the default path as the url. iis will usually redirect
to default.aspx (or whatever is the default).


-- bruce (sqlwork.com)


"Gary K" wrote:

> I realize that there is no good reason for an image button to not have an
> ImageUrl but I have just hit upon a strange problem when converting an
> ASP.NET 1.1 web application to 2.0. An asp:ImageButton control without an
> ImageUrl contained within a WebForm causes a redirect to the default
> document in IIS. This behaviour did not occur in .NET 1.1.
>
> This can easily be duplicated by the following steps :-
>
> 1. Create a new ASP.NET Web Application project in VS2005.
> 2. Add a new Web Form (WebForm1.aspx)
> 3. In the existing Default.aspx add a standard asp:Button to the form and
> add a standard on click event handler containing a simple
> Response.Redirect("WebForm1.aspx");
> 4. Add an asp:ImageButton to WebForm1.aspx, e.g <asp:ImageButton
> ID="ImageButton1" runat="server" />
> 5. Set two breakpoints, one on each Page_Load method of both Web Forms.
>
> Debug the application, you will notice it breakpoints on the Default.aspx
> page load and on the postback when you press the button. This is fine. It
> will then breakpoint on the page load of WebForm1.aspx and *THEN* redirect
> back to Default.aspx and break on the page load event again. The final
> breakpoint does not occur if the ImageUrl is completed or if no default
> document has been setup in IIS.
>
> Thanks
>
> Gary
>
>
>

 
Reply With Quote
 
 
 
 
Gary K
Guest
Posts: n/a
 
      01-08-2008
> this is standard browser behavior. any img, script, css, etc, with a
> src=""
> or missing, will use the default path as the url. iis will usually
> redirect
> to default.aspx (or whatever is the default).


Thanks for the reply Bruce, that does make sense now.

The generated html is different between the versions of Visual Studio, I now
see the src="" has been added :-

VS2003
<input type="image" name="ImageButton1" id="ImageButton1" alt="" border="0"
/>

VS2005
<input type="image" name="ImageButton1" id="ImageButton1" src=""
style="border-width:0px;" />

That explains it.

Thanks

Gary


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ImageButton instantiated need to access imageUrl from the frontend code dphizler@gmail.com ASP .Net 0 11-01-2012 05:13 PM
Imagebutton.ImageUrl won't let read doll ASP .Net 0 09-15-2008 09:12 PM
1.1: Setting ImageUrl of ImageButton does not work DC ASP .Net 2 07-30-2007 01:56 PM
Strange Issue on replacing Image control with ImageButton control jens.buchta@gmx.net ASP .Net 3 09-01-2005 10:28 AM
ImageButton ImageURL question Pradeep ASP .Net Web Controls 0 01-27-2005 10:13 PM



Advertisments