Thursday, March 22, 2012
Strange firing sequence??
I am using custom control COCA that includes an Image IMAGO. IMAGO raises
the Click event for COCA when clicked. All good so far.
The custom control COCA is created dynamically and lives on a Webform1.
Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
and return the coordinates values of COCA to a textbox on the form (done via
VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
Here's the confusing part: when CC1 is clicked on the form the first thing
that happens is the page posts back. Only then, CC1_Clicked fires, and
writes value to the textbox. I see CC1_Clicked running by settping through
and the values ARE being written to the textbox but they never actually show
up on the form because they are written after the postback. A second click
causes a postback, writes out the previous values, runs CC1_Clicked... so
the output on the form is always 1 phase behind.
Scratching my head... shouldn't this be the other way around?
Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
The custom control:
- Implements INamingContainer
- adds the ImageButton control in CreateChildControls()
- Overrides the Render method and uses EnsureChildControls()
- Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
Any ideas? Suggestions? Corrections?
Thanks. Assaf.Sorry folks: spellchecker out of control.
COCA = CC1
IMAGO = IMG1
"Assaf" <at@.isp.com> wrote in message
news:%23jh5xwwPEHA.648@.TK2MSFTNGP10.phx.gbl...
> Hi all. Can't explain this...
> I am using custom control COCA that includes an Image IMAGO. IMAGO raises
> the Click event for COCA when clicked. All good so far.
> The custom control COCA is created dynamically and lives on a Webform1.
> Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
> and return the coordinates values of COCA to a textbox on the form (done
via
> VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
> Here's the confusing part: when CC1 is clicked on the form the first thing
> that happens is the page posts back. Only then, CC1_Clicked fires, and
> writes value to the textbox. I see CC1_Clicked running by settping through
> and the values ARE being written to the textbox but they never actually
show
> up on the form because they are written after the postback. A second click
> causes a postback, writes out the previous values, runs CC1_Clicked... so
> the output on the form is always 1 phase behind.
> Scratching my head... shouldn't this be the other way around?
> Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
> The custom control:
> - Implements INamingContainer
> - adds the ImageButton control in CreateChildControls()
> - Overrides the Render method and uses EnsureChildControls()
> - Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
> Any ideas? Suggestions? Corrections?
> Thanks. Assaf.
>
Strange firing sequence??
I am using custom control COCA that includes an Image IMAGO. IMAGO raises
the Click event for COCA when clicked. All good so far.
The custom control COCA is created dynamically and lives on a Webform1.
Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
and return the coordinates values of COCA to a textbox on the form (done via
VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
Here's the confusing part: when CC1 is clicked on the form the first thing
that happens is the page posts back. Only then, CC1_Clicked fires, and
writes value to the textbox. I see CC1_Clicked running by settping through
and the values ARE being written to the textbox but they never actually show
up on the form because they are written after the postback. A second click
causes a postback, writes out the previous values, runs CC1_Clicked... so
the output on the form is always 1 phase behind.
Scratching my head... shouldn't this be the other way around?
Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
The custom control:
- Implements INamingContainer
- adds the ImageButton control in CreateChildControls()
- Overrides the Render method and uses EnsureChildControls()
- Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
Any ideas? Suggestions? Corrections?
Thanks. Assaf.Sorry folks: spellchecker out of control.
COCA = CC1
IMAGO = IMG1
"Assaf" <at@.isp.com> wrote in message
news:%23jh5xwwPEHA.648@.TK2MSFTNGP10.phx.gbl...
> Hi all. Can't explain this...
> I am using custom control COCA that includes an Image IMAGO. IMAGO raises
> the Click event for COCA when clicked. All good so far.
> The custom control COCA is created dynamically and lives on a Webform1.
> Whenever COCA is clicked, the COCA_Clicked event on Webform1 needs to fire
> and return the coordinates values of COCA to a textbox on the form (done
via
> VB: AddHandler CC1.Click, AddressOf CC1_Clicked).
> Here's the confusing part: when CC1 is clicked on the form the first thing
> that happens is the page posts back. Only then, CC1_Clicked fires, and
> writes value to the textbox. I see CC1_Clicked running by settping through
> and the values ARE being written to the textbox but they never actually
show
> up on the form because they are written after the postback. A second click
> causes a postback, writes out the previous values, runs CC1_Clicked... so
> the output on the form is always 1 phase behind.
> Scratching my head... shouldn't this be the other way around?
> Click >> CC1_Clicked fires >> writes values to textbox >> page postback?
> The custom control:
> - Implements INamingContainer
> - adds the ImageButton control in CreateChildControls()
> - Overrides the Render method and uses EnsureChildControls()
> - Is added to the webform with: Me.FindControl("form1").Controls.Add(CC1)
> Any ideas? Suggestions? Corrections?
> Thanks. Assaf.
Strange Image Problem
I have created a master page and inserted a couple images. When I look at them in design view the appear as a box with an x in it which is not correct. When I view the page in the browser it displays the image. What is the problem?
Here is the master page code:
<%@dotnet.itags.org. Master Language="VB" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<img src="http://pics.10026.com/?src=Images/delilogo.jpg" runat="server"/><br /> <img src="http://pics.10026.com/?src=Images/topmenu.jpg" runat="server"/>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder></center>
</div>
</form>
</body>
</html>
The designer in VS is no good. I would rely on your source and forget the designer most of the time. But if you really want the images to appear in the designer, try draging and dropping your images from VS Solution Explorer onto the designer surface.
Hope this helps.
Hinzamorski ,
try the following:
<asp:ImageID="Image1"runat="server"ImageUrl="~/im.JPG"/>
Hi nzamorski,
I'm sure this should work as well as the asp:Image control.
<img src="http://pics.10026.com/?src=Images/delilogo.jpg" runat="server"/>
First, where is your website project located? Is it IIS project or File System project? Please double check the folder structure if the relative path to Images/delilogo.jpg is right. When the website is located in IIS server, the relatvie path to the image in a virtual directory or a web application might be different.
I agree with the guys above, you can drag and drop the image if you are not certain of the path to the image. But first make sure the Images folder is in the root folder of the project. Thus you will find the folder is appearing in the Solution Explorer window of Visual Studio. Pick up the image and drag & drop it into the Design View will be simpler.
Hope it helps.
Strange Issue on replacing Image control with ImageButton control
I'm using a DataGrid with a template column to display an Image inside
of it. I'm hooking into its OnPrerender-Event to set the
ImageURL-Property dynamically.
Everything works just fine here, until I thought "It would be cool, if
the user could click on that image..". So I replaced the Image-Control
with an ImageButton.
My Problem is, that the ImageButton doesn't fire any events. Any other
control works just fine but I'm having no luck getting the ImageButton
to work.
I'm happy about any ideas..
Regards
Jens
---------------
Code-Snippet
------
aspx-Page
<asp:TemplateColumn HeaderText="Images">
<ItemTemplate>
<asp:Image id="imgPic" runat="server"
OnPreRender="imgPic_PreRender"></asp:Image>
<asp:ImageButton id="ibtnPic" runat="server"
OnPreRender="ibtnPic_PreRender"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn
------
CodeBehind
protected void imgPic_PreRender(object sender, System.EventArgs e)
{
//this works as expected
Image img = sender as Image;
if (img == null)
{
return;
}
img.ImageURL = "dynamically-assigned.jpg";
}
protected void ibtnPic_PreRender(object sender, System.EventArgs e)
{
//this does not work
//
//if I rename this Method for testing purposes, the Page can't
//be loaded, as it doesn't find this Method
//
//if I set a Break-Point to first method, the program does not
//stop
ImageButton ibtn = sender as ImageButton;
if (ibtn == null)
{
return;
}
ibtn.ImageURL = "dynamically-assigned.jpg";
}Jens,
With thwe ImageButton you can setup both the Click and Command events. Do
you setup one of them?
Eliyahu
<jens.buchta@.gmx.net> wrote in message
news:1125557636.729770.63420@.g49g2000cwa.googlegro ups.com...
> Hi!
> I'm using a DataGrid with a template column to display an Image inside
> of it. I'm hooking into its OnPrerender-Event to set the
> ImageURL-Property dynamically.
> Everything works just fine here, until I thought "It would be cool, if
> the user could click on that image..". So I replaced the Image-Control
> with an ImageButton.
> My Problem is, that the ImageButton doesn't fire any events. Any other
> control works just fine but I'm having no luck getting the ImageButton
> to work.
> I'm happy about any ideas..
> Regards
> Jens
>
> ---------------
> Code-Snippet
> ------
> aspx-Page
> <asp:TemplateColumn HeaderText="Images">
> <ItemTemplate>
> <asp:Image id="imgPic" runat="server"
> OnPreRender="imgPic_PreRender"></asp:Image>
> <asp:ImageButton id="ibtnPic" runat="server"
> OnPreRender="ibtnPic_PreRender"></asp:ImageButton>
> </ItemTemplate>
> </asp:TemplateColumn>
> ------
> CodeBehind
> protected void imgPic_PreRender(object sender, System.EventArgs e)
> {
> //this works as expected
> Image img = sender as Image;
> if (img == null)
> {
> return;
> }
> img.ImageURL = "dynamically-assigned.jpg";
> }
> protected void ibtnPic_PreRender(object sender, System.EventArgs e)
> {
> //this does not work
> //
> //if I rename this Method for testing purposes, the Page can't
> //be loaded, as it doesn't find this Method
> //
> //if I set a Break-Point to first method, the program does not
> //stop
> ImageButton ibtn = sender as ImageButton;
> if (ibtn == null)
> {
> return;
> }
> ibtn.ImageURL = "dynamically-assigned.jpg";
> }
Thanks for your Answer!
I can set up the Click event to parse the CommandName and
CommandArgument. This is a way to react on the users PostBack, no
problem here.
The problem is, that i need the PreRender event to handle the ImageURL
before the ImageButton is drawn. At the moment, I can't catch this
event in the same way, as it works for the Image-control, so that the
image, the ImageButtons renders, is "none".
Jens
Why can't you handle the ImageUrl in Click event?
Eliyahu
<jens.buchta@.gmx.net> wrote in message
news:1125566088.815538.95660@.o13g2000cwo.googlegro ups.com...
> Thanks for your Answer!
> I can set up the Click event to parse the CommandName and
> CommandArgument. This is a way to react on the users PostBack, no
> problem here.
> The problem is, that i need the PreRender event to handle the ImageURL
> before the ImageButton is drawn. At the moment, I can't catch this
> event in the same way, as it works for the Image-control, so that the
> image, the ImageButtons renders, is "none".
> Jens
Strange issue with ImageButton with no ImageUrl
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
Garythis is standard browser behavior. any img, script, css, etc, with a src="http://pics.10026.com/?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
>
>
> this is standard browser behavior. any img, script, css, etc, with a
> src="http://pics.10026.com/?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="http://pics.10026.com/?src=" has been added :-
VS2003
<input type="image" name="ImageButton1" id="ImageButton1" alt="" border="0"
/>
VS2005
<input type="image" name="ImageButton1" id="ImageButton1" src="http://pics.10026.com/?src="
style="border-width:0px;" />
That explains it.
Thanks
Gary
Strange Issue on replacing Image control with ImageButton control
I'm using a DataGrid with a template column to display an Image inside
of it. I'm hooking into its OnPrerender-Event to set the
ImageURL-Property dynamically.
Everything works just fine here, until I thought "It would be
the user could click on that image..". So I replaced the Image-Control
with an ImageButton.
My Problem is, that the ImageButton doesn't fire any events. Any other
control works just fine but I'm having no luck getting the ImageButton
to work.
I'm happy about any ideas..
Regards
Jens
---
Code-Snippet
aspx-Page
<asp:TemplateColumn HeaderText="Images">
<ItemTemplate>
<asp:Image id="imgPic" runat="server"
OnPreRender="imgPic_PreRender"></asp:Image>
<asp:ImageButton id="ibtnPic" runat="server"
OnPreRender="ibtnPic_PreRender"></asp:ImageButton>
</ItemTemplate>
</asp:TemplateColumn>
CodeBehind
protected void imgPic_PreRender(object sender, System.EventArgs e)
{
//this works as expected
Image img = sender as Image;
if (img == null)
{
return;
}
img.ImageURL = "dynamically-assigned.jpg";
}
protected void ibtnPic_PreRender(object sender, System.EventArgs e)
{
//this does not work
//
//if I rename this Method for testing purposes, the Page can't
//be loaded, as it doesn't find this Method
//
//if I set a Break-Point to first method, the program does not
//stop
ImageButton ibtn = sender as ImageButton;
if (ibtn == null)
{
return;
}
ibtn.ImageURL = "dynamically-assigned.jpg";
}Jens,
With thwe ImageButton you can setup both the Click and Command events. Do
you setup one of them?
Eliyahu
<jens.buchta@.gmx.net> wrote in message
news:1125557636.729770.63420@.g49g2000cwa.googlegroups.com...
> Hi!
> I'm using a DataGrid with a template column to display an Image inside
> of it. I'm hooking into its OnPrerender-Event to set the
> ImageURL-Property dynamically.
> Everything works just fine here, until I thought "It would be
> the user could click on that image..". So I replaced the Image-Control
> with an ImageButton.
> My Problem is, that the ImageButton doesn't fire any events. Any other
> control works just fine but I'm having no luck getting the ImageButton
> to work.
> I'm happy about any ideas..
> Regards
> Jens
>
> ---
> Code-Snippet
> --
> aspx-Page
> <asp:TemplateColumn HeaderText="Images">
> <ItemTemplate>
> <asp:Image id="imgPic" runat="server"
> OnPreRender="imgPic_PreRender"></asp:Image>
> <asp:ImageButton id="ibtnPic" runat="server"
> OnPreRender="ibtnPic_PreRender"></asp:ImageButton>
> </ItemTemplate>
> </asp:TemplateColumn>
> --
> CodeBehind
> protected void imgPic_PreRender(object sender, System.EventArgs e)
> {
> //this works as expected
> Image img = sender as Image;
> if (img == null)
> {
> return;
> }
> img.ImageURL = "dynamically-assigned.jpg";
> }
> protected void ibtnPic_PreRender(object sender, System.EventArgs e)
> {
> //this does not work
> //
> //if I rename this Method for testing purposes, the Page can't
> //be loaded, as it doesn't find this Method
> //
> //if I set a Break-Point to first method, the program does not
> //stop
> ImageButton ibtn = sender as ImageButton;
> if (ibtn == null)
> {
> return;
> }
> ibtn.ImageURL = "dynamically-assigned.jpg";
> }
>
Thanks for your Answer!
I can set up the Click event to parse the CommandName and
CommandArgument. This is a way to react on the users PostBack, no
problem here.
The problem is, that i need the PreRender event to handle the ImageURL
before the ImageButton is drawn. At the moment, I can't catch this
event in the same way, as it works for the Image-control, so that the
image, the ImageButtons renders, is "none".
Jens
Why can't you handle the ImageUrl in Click event?
Eliyahu
<jens.buchta@.gmx.net> wrote in message
news:1125566088.815538.95660@.o13g2000cwo.googlegroups.com...
> Thanks for your Answer!
> I can set up the Click event to parse the CommandName and
> CommandArgument. This is a way to react on the users PostBack, no
> problem here.
> The problem is, that i need the PreRender event to handle the ImageURL
> before the ImageButton is drawn. At the moment, I can't catch this
> event in the same way, as it works for the Image-control, so that the
> image, the ImageButtons renders, is "none".
> Jens
>