Showing posts with label imagebutton. Show all posts
Showing posts with label imagebutton. Show all posts

Saturday, March 24, 2012

Triggering Update Panel from Dynamically Built Triggers

I have a page which has two content areas (Left, Center). The Left hand content contains two repeaters, both of which have an imagebutton who's itemcommand triggers an update of the content in the Center area. The Center Area has an update panel in it. The triggers are dynamically generated because the repeaters are in panels, and I needed to use the findcontrol() command to get access to them.

Code works great on my laptop (localhost), gives an error when I move it to the server. Error is:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing this request on the server. The status code returned from the server was: 500.

Here's my UpdatePanel:

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Repeater ID="rMain" DataSourceID="srcMain" OnItemCommand="rmain_itemCommand" runat="server"> <ItemTemplate> <asp:Label ID="lblTitle" Text='<%#Eval("Description")%>' runat="server" CssClass="verorangeHeader" /><asp:Label ID="ProductID" runat="server" Text='<%# Eval("idProduct") %>' Visible="false"></asp:Label><asp:Label ID="lblSKU" runat="server" Text='<%# Eval("Sku") %>' Visible="False" /><br /><br /> <table border="0" cellpadding="1" cellspacing="1"> <tr> <td > <asp:Label ID="lblDetails" Text='<%#Eval("Details")%>' runat="server" CssClass="ver11bluebold" /> </td> <td ><img src='<%# formatPhoto(Eval("ImageURL")) %>' /></td> </tr> <tr> <td colspan="2" align="right" valign="top">Priced from: <asp:Label ID="lblPrice" Text='<%# formatPrice(Eval("Price")) %>' runat="server" CssClass="verorange" />   <asp:ImageButton ID="btnSpecifications" ImageURL="images/btn_specifications.gif" runat="server" /><asp:ImageButton ID="btnPhotoGallery" ImageURL="images/btn_photo-gallery.gif" runat="server" /><asp:ImageButton ID="btnBuyNow" ImageURL="images/buy-bm-clear.gif" runat="server" CommandName="Update" /></td> </tr> </table></ItemTemplate></asp:Repeater></ContentTemplate></asp:UpdatePanel>

Here's the code that creates the triggers:

Private Sub Page_Init(ByVal senderAs Object,ByVal eAs EventArgs)Handles MyBase.Init'Add TriggersDim ap1As AsyncPostBackTrigger =New AsyncPostBackTrigger()Dim ap2As AsyncPostBackTrigger =New AsyncPostBackTrigger() ap1.ControlID = pnlProduct1.FindControl("rY5").UniqueID ap1.EventName ="ItemCommand" ap2.ControlID = pnlProduct2.FindControl("r52").UniqueID ap2.EventName ="ItemCommand" UpdatePanel1.Triggers.Add(ap1) UpdatePanel1.Triggers.Add(ap2)End Sub

Any suggestions?

Jennifer

Take a look at this post...http://forums.asp.net/p/1139950/1831145.aspx

-Damien


Got it fixed. It was actually related to a bug in my Master Page!

Thanks for the help!

Jennifer


To fix this problem, you can add the follow code in your web.config

<system.web>
<pages validateRequest="false">
</system.web>.

Wednesday, March 21, 2012

Trouble w/ Atlas and Custom User Control

I am trying to create a simple user control that shows a hidden div when an imagebutton is clicked. It works perfectly in a regular page, but in a user control it is conventionally posting back rather than refreshing via Atlas. I have an <atlas:ScriptManager> tag in the page for the control. Below is my code for the control:

<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="RatingsBar.ascx.cs" Inherits="UserControls_RatingsBar" %>
<asp:ImageButton ID="showBarGraphButton" runat="server" ImageUrl="~/_Images/bargraph.gif"
OnClick="showBarGraphButton_Click" />

<atlas:UpdatePanel ID="updatePanel1" runat="server" RenderMode="Inline">
<Triggers>
<atlas:ControlEventTrigger ControlID="showBarGraphButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="barGraphPopup" CssClass="popupHide" runat="server">
<asp:Image ID="sampleImage" runat="server" ImageUrl="~/_Images/barGraphExample.gif"/>
</asp:Panel>
</ContentTemplate>
</atlas:UpdatePanel>

Below is my code for the default.aspx page:
<%@dotnet.itags.org. Page Title="Hi There" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"Inherits="_Default" %><%@dotnet.itags.org. Register TagPrefix="uc" TagName="Karmevent" Src="~/_UserControls/Karmevent.ascx" %><%@dotnet.itags.org. Register TagName="RatingsBar" TagPrefix="uc" Src="~/_UserControls/RatingsBar.ascx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Untitled Page</title><link href="_Stylesheets/StyleSheet.css" rel="stylesheet" type="text/css" /><atlas:ScriptManager ID="ScriptManager" runat="server" /></head><body><form id="form1" runat="server"><uc:RatingsBar ID="rb1" runat="server" /></form></body></html>
Nevermind, everyone. I re-did the code from scratch and it works. I still have no idea what I did wrong, but it's working now.