In short: I want to enable a button i.e. outside UpdatePanel when I click on a button from inside UpdatePanel.
Problem: The button enables but tags i and asp:Localize are not showing in the rendered code after button click from UpdatePanel updPnlOfferings
Detail:
I have a DataList inside UpdatePanel which contains delete button for every item in the list. delete button is firing an event on server which deletes the record and disables a button (i.e. outside of the UpdatePanel.
As someone suggested I kept my button(which need to be disabled) in UpdatePanel below
<asp:UpdatePanel ID="updPnlCourse" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="lnkDeleteCourseDetails" runat="server" OnClick="lnkDeleteCourseDetails_Click">
<i class="icon-remove-sign"></i>
<asp:Localize ID="Localize6" runat="server" Text="<%$ Resources:CBLabels, LBL_DeleteDetails %>" />
</asp:LinkButton>
<asp:ConfirmButtonExtender ID="lnkDeleteCourseDetails_ConfirmButtonExtender" runat="server"
ConfirmText='Are you sure you want to delete this course?' Enabled="True" TargetControlID="lnkDeleteCourseDetails">
</asp:ConfirmButtonExtender>
</ContentTemplate>
</asp:UpdatePanel>
The Main UpdatePanel which is firing the event is below
<asp:UpdatePanel ID="updPnlOfferings" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlDSOfferings" runat="server">
<asp:DataList ID="dtlstOfferings" runat="server" OnItemCommand="dtlstOfferings_ItemCommand" EnableViewState="true">
</asp:DataList></asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
on dtlstOfferings_ItemCommand event I coded this
lnkDeleteCourseDetails.Enabled = true;
lnkDeleteCourseDetails.ToolTip = "";
lnkDeleteCourseDetails_ConfirmButtonExtender.Enabled = true;
updPnlCourse.Update();
This is a known problem as specified in this link.
The solution is to put all your content that are there inside the LinkButton, within a place holder like below, or make all the child controls as server controls.
<asp:LinkButton ID="lnkDeleteCourseDetails" runat="server" OnClick="lnkDeleteCourseDetails_Click">
<asp:PlaceHolder runat="server">
<i class="icon-remove-sign"></i>
<asp:Localize ID="Localize6" runat="server" Text="<%$ Resources:CBLabels, LBL_DeleteDetails %>" />
</asp:PlaceHolder>
</asp:LinkButton>
Related
I am working on a page that is using a gridview to display data. I have some dynamically created textboxes inside an ItemTemplate which contains several textboxes per row. Now I also have an update panel that is using ajax and should only render once my link button is clicked. The datalist is bound in my code behind after the I would like this to occur without causing a full postback. However, right now when I click the link button it causes a full post-back which eliminates my dynamically created controls.
I feel I am very close to a solution. I need one of these to happen (option 1 seems more useful):
Do not cause a postback when the linkbutton is clicked, but still render my full datalist in the update panel
or
my dynamically created controls are not removed during post back.
Here is my code:
<ItemTemplate>
[ <asp:LinkButton ID="SelectCommand" CommandName="Select" runat="server" Text="+" CssClass="sunocoBold"/> ]
<%-- start sub panel--%>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Vertical"
OnItemCommand="DataList_OnItemCommand">
<ItemTemplate>
<asp:LinkButton ID="Select" CommandName="SelectCommand" CommandArgument='<%#Eval("ship_to_num")%>' runat="server" Text='<%#Eval("ship_to_num")%>' />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
<%-- end sub panel--%>
</ItemTemplate>
<asp:TemplateField HeaderText="Site Owner" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<asp:Panel ID="pnlNames" runat="server">
</asp:Panel>
<%-- <asp:Literal ID="NameList" runat="server" /> --%>
</ItemTemplate>
</asp:TemplateField>
UpdatePanel.Triggers is made for this!
Take a look at it here: Understanding UpdatePanel.Triggers
I know I am missing something simple but I can't seem to get my button to post back. This is how my form looks (simplified):
<asp:ScriptManager id="smMembersArea" runat="server" EnableViewState="False" />
<asp:UpdatePanel id="updAccounts" runat="server" EnableViewState="True">
<ContentTemplate>
<asp:Repeater id="rptrWishList" runat="server" EnableViewState="False">
<HeaderTemplate></HeaderTemplate>
<ItemTemplate>
<asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO"/>
</ItemTemplate>
<FooterTemplate></FooterTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
The update panel doesn't do anything and nothing happens in FEdit.
When I remove the updatepanel my FEdit event is triggered correctly.
Can anyone point me in the right direction please.
Thanks.
what you can do is add CommandName="Select" to your button
so your button now looks like this
<asp:Button id="bWLAmend" onclick="FEdit" runat="server" cssclass="button bg" EnableViewState="True" Text="GO" CommandName="Select"/>
and use itemcommand of the repeater rptrWishList_ItemCommand
so when you click the button, itemcommand event of repeater fires.
what language you are using in code behind..?I may be able to suggest something else.
i'm kinda new in web programming,
i'm trying to design a search page.
i want to creating few radio buttons where each click on a radio button will show a div
contains the related search div's.
and from there to do the query to the database(not related to the post)
how can i do that ?
tried to search for it , and didn't get good answer.
i want that the change of the page will be in server side and not the client side.
p.s.
i have been working with ajax control kit so far..
thanks for the help.
You just need an UpdatePanel, radio buttons and a MultiView control.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:RadioButton ...
<asp:RadioButton ...
</div>
<asp:MultiView ID="mvAll" runat="server" ActiveViewIndex="-1">
<asp:View ID="vwFirst" runat="server">
</asp:View>
<asp:View ID="vwSecond" runat="server">
</asp:View>
...
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
When the selected radio button changed you just set the View related to be active,
mvAll.SetActiveView(ViewIDYouNeed);
You can accomplish this with Panels and an Update Panel.
<asp:RadioButton ID="rdo1" AutoPostBack="true" GroupName="radios" runat="server" OnCheckedChanged="ShowDivs" />
<asp:RadioButton ID="rdo2" AutoPostBack="true" GroupName="radio2" runat="server" OnCheckedChanged="ShowDivs" />
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server" Visible="false"></asp:Panel>
<asp:Panel ID="pnl2" runat="server" Visible="false"></asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdo1" />
<asp:AsyncPostBackTrigger ControlID="rdo2" />
</Triggers>
</asp:UpdatePanel>
You would then handle setting the Visible property of the panels in your ShowDivs method in your code behind.
Or, you could use jquery/javascript to accomplish this.
<input type="radio" onClick="ShowDiv(1)" />
function ShowDiv(id) {
HideDivs();
$(id).show('slow');
}
I have UserControl and within that control i have asp:ListView. Inside the ListView i have a asp:LinkButton. When i click on the LinkButton the control raises full postback, no matter if the UserControl is inside UpdatePanel or is not.
UserControl:
<asp:ListView ID="lvImages" runat="server" OnItemCommand="lvImages_ItemCommand">
<ItemTemplate>
<div>
<asp:Image runat="server" ID="imgImageThumb" ImageUrl='<%#Eval("Image") %>' GenerateEmptyAlternateText="true" />
<asp:LinkButton runat="server" ID="lbtnImageAdd" CommandName="Add" CommandArgument='<%#Container.DisplayIndex %>'
CausesValidation="false" Text="Add" />
</div>
<ItemTemplate>
</asp:ListView>
Page:
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<cuc:UserControl ID="cucUserControl" runat=server/>
</ContentTemplate>
</asp:UpdatePanel>
You need to set the properties to let the update panel know what to trigger off of. Try setting ChildrenAsTrigger=true.
I have a modalpopupExtender which is opened when edit button is clicked.In that i have a gridview in which if click any row the popup gets hidden and the values are displayed on the page.The problem is that when i keep this code in the update panel the modalpopupextender is not getting hidden after clicking in the gridview.I have a master page in my page and using Ajax modal popup extender
are you doing a full postback? If so, in the Click event why not use ModalPopup.Hide()??
I saw the same behavior what i did was putting modelpopup before update panel that way it worked
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<cc1:ModalPopupExtender ID="mpeScreenFreez"
runat="server"
BackgroundCssClass="modalBackground"
DropShadow="true"
TargetControlID="btnDummy"
PopupControlID="panFreeze">
</cc1:ModalPopupExtender>
<asp:Panel ID="panFreeze" runat="server" CssClass="modalPopup" style="display:none;">
<asp:Label ID="lblSave" runat="server" Font-Bold="true" Text="Sending the Quote....">
</asp:Label>
</asp:Panel>
<asp:Button ID="btnDummy" runat="server" CssClass="hidden" />
<asp:UpdatePanel ID="upDirectHomOwnrPremQuote" runat="server">
<ContentTemplate></ContentTemplate>