Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Thursday, March 22, 2012

Strange Issue on replacing Image control with ImageButton control

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";
}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 in aspx pages

Hi
I was writing some aspx pages when i experimented a strange issue.
I have a div tag like this:
<div id="divCourses1" style="<%=GetDisplayStyle(eidlevel,
arrIdLevel[0])%>">
Now, as long as i don't switch the page to HTML into Design everything
works fine.
But if i switch the page into Design and therefore into HTML again,
then all the attribute style and its content disappear.
I have tryed many times and the behavior is always the same.
Anyone knows anything about that issue? It's a known issue?
I would avoid to use html runat-sever objects, if possible.
Thanks.2003 does bad things when switching between HTML and Design view, it is a
known issue and the only way to fix it is to migrate your code to 2005 :(
The solution I would recomment is to your a runat=server object, but i see
you have reservations against that.
Karl
http://www.openmymind.net/
"Joneleth" <Joneleth_76@.hotmail.com> wrote in message
news:1139391607.599439.317260@.z14g2000cwz.googlegroups.com...
> Hi
> I was writing some aspx pages when i experimented a strange issue.
> I have a div tag like this:
> <div id="divCourses1" style="<%=GetDisplayStyle(eidlevel,
> arrIdLevel[0])%>">
> Now, as long as i don't switch the page to HTML into Design everything
> works fine.
> But if i switch the page into Design and therefore into HTML again,
> then all the attribute style and its content disappear.
> I have tryed many times and the behavior is always the same.
> Anyone knows anything about that issue? It's a known issue?
> I would avoid to use html runat-sever objects, if possible.
> Thanks.
>
Karl Seguin [MVP] wrote:
> 2003 does bad things when switching between HTML and Design view, it is a
> known issue and the only way to fix it is to migrate your code to 2005 :(
ok.

> The solution I would recomment is to your a runat=server object, but i see
> you have reservations against that.
> Karl
After trying for several minutes i realized you're right. :)
I see no other way than using server-side objects to avoid that bug.
Thanks.

Strange issue in aspx pages

Hi

I was writing some aspx pages when i experimented a strange issue.
I have a div tag like this:
<div id="divCourses1" style="<%=GetDisplayStyle(eidlevel,
arrIdLevel[0])%>">
Now, as long as i don't switch the page to HTML into Design everything
works fine.
But if i switch the page into Design and therefore into HTML again,
then all the attribute style and its content disappear.
I have tryed many times and the behavior is always the same.
Anyone knows anything about that issue? It's a known issue?
I would avoid to use html runat-sever objects, if possible.

Thanks.2003 does bad things when switching between HTML and Design view, it is a
known issue and the only way to fix it is to migrate your code to 2005 :(

The solution I would recomment is to your a runat=server object, but i see
you have reservations against that.

Karl

--
http://www.openmymind.net/

"Joneleth" <Joneleth_76@.hotmail.com> wrote in message
news:1139391607.599439.317260@.z14g2000cwz.googlegr oups.com...
> Hi
> I was writing some aspx pages when i experimented a strange issue.
> I have a div tag like this:
> <div id="divCourses1" style="<%=GetDisplayStyle(eidlevel,
> arrIdLevel[0])%>">
> Now, as long as i don't switch the page to HTML into Design everything
> works fine.
> But if i switch the page into Design and therefore into HTML again,
> then all the attribute style and its content disappear.
> I have tryed many times and the behavior is always the same.
> Anyone knows anything about that issue? It's a known issue?
> I would avoid to use html runat-sever objects, if possible.
> Thanks.
Karl Seguin [MVP] wrote:
> 2003 does bad things when switching between HTML and Design view, it is a
> known issue and the only way to fix it is to migrate your code to 2005 :(

ok.

> The solution I would recomment is to your a runat=server object, but i see
> you have reservations against that.
> Karl

After trying for several minutes i realized you're right. :)
I see no other way than using server-side objects to avoid that bug.

Thanks.

Strange Issue on replacing Image control with ImageButton control

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 , 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.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 , 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.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
>