Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Saturday, March 24, 2012

Okay, how do I get the "name" of the image?...

The following code is supposed to create a rollover image for an ImageButton WebControl that is inside of a Repeater WebControl. The only problem is that it won't work because I don't know how to get the "name" of the image that ASP.NET gives the image at runtime.. Here is the code...


protected void rptrNewReleases_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
ImageButton imgbtnImageButton = (ImageButton)e.Item.FindControl("imgAddToCart");

// (e) needs to be replaced with the "name" this image is given at runtime, but how?
imgbtnImageButton.Attributes.Add("onmouseover", "MM_swapImage('" + (e) + "','','button_addtocart_on.jpg',1)");
imgbtnImageButton.Attributes.Add("onmouseout", "MM_swapImgRestore ()");
}

The name of the image in the first Item is something like name="rptrRepeateRegion:ctl0:imgAddToCartButton"

In the second (Alternating) Item it is name="rptrRepeateRegion:ctl1:imgAddToCartButton"

and so forth...

Is there any function to get this name that ASP.NET creates?

for example: e.Item.ItemName (something like this...)

Thanks (hope this makes sense)Have you tried imgbtnImageButton.ID?

Friday, March 16, 2012

OMG please help. Parent UpdatePanel refreshing with nested UpdatePanel

Angry I have two update panels, lets call them A & B

B is nested inside A

B has a trigger registered to a timer so it updates every 30 seconds. A is updating too, why?

Both are set to conditional update, all other options are at default. Scriptmanager PartialPageRendering=true

Please help, I'm going insane.

Then a lesser worry for me, if you know,, how can I give a textbox located in A focus (cursor) after an update?

Set the ChildrenAsTriggers of UpdatePanel A to FALSE

Thanks


I did that and I'm still getting it.

Panel A's Page_load event also gets fired before B's. and the tmr is definitely registered only to B. the tmr is also located inside the B panel. The is a UpdateProgress control inside A and it triggers with B and A.

anything else anyone cant think of...

thanks in advance for any tips.


did you ever figure out this issue?

I did, however it was one of those things where I just kept moving things around and it eventually worked. But I will say that my panel A's (the parent) will still have its page_load event fired when b is updated, I just have to test to see if the timer is what caused the postback and if so run my code to change what I need to in B and change nothing in A.

Panel A (parent) is set to conditional and children as triggers False,

Panel B (nested) is set to update always with children as triggers set to true.

the timer is inside B but is NOT registered is a trigger.

On Page Load, looking to see if Grid is populated.

I have run into this a few times looking for a Textbox located inside of a form or a gridview inside of a loginview.

If it's not inside of the FormView, Intellisense picks it right up. how can I get Gridview2 located inside of the formview to check at page_load?


<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{

}
</script
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table style="width: 100%">
<tr>
<td style="width: 100px; vertical-align: top; text-align: left;">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server" CreateUserText="Need to Register?" CreateUserUrl="~/Signup.aspx" PasswordRecoveryText="Forget your Password?" PasswordRecoveryUrl="~/PasswordRecovery.aspx" Height="208px">
</asp:Login>
</AnonymousTemplate>
<LoggedInTemplate>
Welcome Back
<asp:LoginName ID="LoginName1" runat="server" />
<br />
<table style="; position: static">
<tr>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 400px">
<span style="font-size: 14pt; color: dimgray"><strong>Today's Sales<asp:Label ID="Label6"
runat="server" Text="Today's Sales Label"></asp:Label></strong></span></td>
</tr>
<tr>
<td style="width: 400px">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataSourceID="SqlDataSource2"
ForeColor="Black" GridLines="None" Style="width: 400px">
<FooterStyle BackColor="Tan" />
<Columns>

In your supplied code, there is no FormView. Your GridView however is within a LoginView which requires that you be logged in to have access to the GridView.