Event not associated on control error while using updatepanel - c#

I am using an update panel inside which I have a treeview control. I wrote an async trigger with the same. I am getting an error which I couldn't solve as I am seeing it for the first time. I also got this error for the my control which was in update panel but that got solved as i used $ for separation of parent and child. Now i am having problem for finding event name. Following is my error
Could not find an event named 'PopulateNode' on associated control 'TreeView_Parent_Child' for the trigger in UpdatePanel '_updatepnlTreeview'.
My code is
<asp:Panel ID="Panel1" Visible="true" runat="server"
ScrollBars="Auto">
<div style="overflow: auto; height: 400px; width:230px; border-right: solid; border-right-color: gray">
<asp:UpdatePanel ID="_updatepnlTreeview" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:TreeView ID="TreeView_Parent_Child" EnableClientScript="true" align="left"
AutoGenerateDataBindings="true" LeafNodeStyle-ForeColor="Black" NodeStyle-ForeColor="Black"
PopulateNodesFromClient="true" runat="server" Font-Names="Arial"
OnTreeNodePopulate="PopulateNode"
HoverNodeStyle-BackColor="ActiveBorder" Font-Size="Small" ImageSet="Arrows" NodeStyle-HorizontalPadding="5px">
<HoverNodeStyle Font-Bold="true" BackColor="Beige" />
<Nodes>
</Nodes>
<NodeStyle ForeColor="Black" />
<LeafNodeStyle ForeColor="Black" />
</asp:TreeView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TreeView_Parent_Child" EventName="PopulateNode" />
</Triggers>
</asp:UpdatePanel>
</div>
</asp:Panel>

The EventName needs to be changed to the name of the event instead of the method:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="TreeView_Parent_Child" EventName="TreeNodePopulate" />
</Triggers>

Related

reload on button click in

Here is my aspx:
<asp:Panel ID="pnl_updateClinicVisit" runat="server" CssClass="modalPopupClinicVisitEntry2" DefaultButton="bt_editClinicVisit_submit" Style="display:none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="AddMedicationChange" ClientIdMode="Static" runat="server" Text="Add Med Change" OnClick="AddMedicationChange_Click" />
<asp:Panel ID="AddNewMedicationPanel" runat="server">
<asp:TextBox ID="NewDrugName" OnTextChanged="NewDrugName_TextChanged" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="NewDrugNameAutoCompleteExtender"
runat="server"
TargetControlID="NewDrugName"
MinimumPrefixLength="1"
EnableCaching="false"
CompletionSetCount="1"
CompletionInterval="500"
ServiceMethod="GetDrugs">
</asp:AutoCompleteExtender>
<asp:DropDownList OnSelectedIndexChanged="NewDrugChange_SelectedIndexChanged" ID="NewDrugChange" runat="server">
<asp:ListItem>Drug +</asp:ListItem>
<asp:ListItem>Drug -</asp:ListItem>
<asp:ListItem>Dose ↑</asp:ListItem>
<asp:ListItem>Dose ↓</asp:ListItem>
</asp:DropDownList>
<asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="SubmitMedChange" runat="server" Text="Add to Visit" OnClick="SubmitMedicationChange_Click" />
</asp:Panel>
<asp:ModalPopupExtender ID="updateClinicModalPopupExtender" runat="server" TargetControlID="bt_editClinicVisit_dummy"
PopupControlID="pnl_updateClinicVisit" CancelControlID="bt_editClinicVisit_cancel"
DropShadow="true" BackgroundCssClass="modalBackground" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
For some reason my page is reloading when I click the "AddnewMdication" and "SubmitMedChange" buttons. When I have the AutoPostBack=false UseSubmitBehavior=false, the events fire and then the page reloads. If I don't have these attributes then the page reloads before the events even fire. How do I get AJAX functionality within this modal?
Try setting your Buttons as an AsyncPostBackTrigger. You can do this by adding in the Triggers section and declaring the UpdatePanel as a conditional update.
For example
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AddMedicationChange" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="SubmitMedChange" EventName="Click" />
</Triggers>
<ContentTemplate>
<%-- Your code here --%>
</ContentTemplate>
</asp:UpdatePanel>
What this should do is to explicitly declare that those two buttons as being Async.
If this doesn't work, will you please post the relevant code to your two button OnClick events? AddMedicationChange_Click and SubmitMedicationChange_Click
If you try to interact with controls outside of the UpdatePanel in your code-behind during an asyncpostback, odd things can start to happen.

triggered button cause fullpostback

I've got an updatePanel and a button which triggered in it.
However, the button causes full postback instead of partial one.
Here's my Code:
<asp:Button ID="cEvent" runat="server" Text="צור יום" Width="80px"
Height="40px" Font-Size="Medium" onclick="cEvent_Click" CausesValidation="false"/>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id = "updatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cEvent" EventName="Click"/>
</Triggers>
<ContentTemplate>
<div id="yesEve" runat="server" visible="false" style="width:95%; float:right; margin-left:5%; padding-top:20px; margin-bottom:20px;">
<table id="mytable" cellspacing="0" runat="server">
</table>
</div>
<div id="errorMsg" runat="server" visible="false" style="width:100%; text-align:center; float:right;">
<asp:label visible="true" ID="msg1" Font-Size="Medium" runat="server" Font-Bold="true" Text = "היום נמחק בהצלחה"></asp:label>
</div>
<div id="noEve" style="width:100%; padding-top:20px; float:right; text-align:center; margin-bottom:20px;" runat="server" visible="false">
<asp:label visible="true" ID="stamLabel" Font-Size="Medium" runat="server" Font-Bold="true" Text = "לא קיימים ימים פתוחים"></asp:label>
</div>
<asp:LinkButton ID ="remove" runat="server"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
I really need some help with that... i'm searching for hours all over the web to find an answer.
Thanks, Matan
In the code behind, you can try adding this line:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button1);
There is nothing wrong with your code, you have a conflict somewhere with code(ClientIDs) you haven't show us or a JavaScript error breaking the page.
Here's a template for how to do this from a microsoft tutorial page:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
More information here:
microsoft tutorial

I have a problem with TabContainer control

It doesnt appear on the screen when I run it..but it does appear in visual studio 2010 in the design view. Also i want to set the tabs from left to right to right to left:
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="2"
Height="584px" Width="739px" AutoPostBack="True" BackColor="#666699"
BorderColor="#666699">
<asp:TabPanel ID="Questions" runat="server" HeaderText="שאלות">
<ContentTemplate>
<asp:GridView runat="server" Height="547px"
style="margin-left: 2px; margin-top: 15px" Width="667px">
</asp:GridView>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="Answers" runat="server" HeaderText="תשובות">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" Height="547px"
style="margin-top: 17px" Width="666px">
</asp:GridView>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="Responses" runat="server" HeaderText="תגובות">
<ContentTemplate>
<asp:GridView ID="GridView2" runat="server" Height="547px"
style="margin-top: 21px" Width="666px">
</asp:GridView>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
For set tabs right to left add the following style onto the page:
.ajax__tab_header
{
text-align: right;
}
But for resolving visibility issue it is not enough information. Do you play with visibility property in code-behind?
Or even better:
.ajax__tab_header
{
direction: rtl;
}
that will switch the order of the tabs too. (for rtl languages)

Modal Popup Extender animation in ASP.net

I am currently developing an ASP.net c# application. I have a grid view which has bound link buttons inside. When the link button is pressed I want to display the modal popup using a fade in animation and a fade out animation when a button inside the modal popup is clicked.
I have added the animation extender into the code and set the TargetControlID to the ID of the link button, however, when I try to run the website it displays the error System.InvalidOperationException the TargetControID of ModalPopupExtender is not valid. A control with ID 'sofLink' could not be found. sofLink is the ID of the LinkButton.
Below is the code for the grid view
<asp:GridView ID="tblSoftware" runat="server" Width="100%"
EnableModelValidation="True" AutoGenerateColumns="False"
onselectedindexchanged="tblSoftware_SelectedIndexChanged"
CellPadding="2">
<Columns>
<asp:TemplateField HeaderText="Software Name">
<ItemTemplate>
<asp:LinkButton ID="sofLink" Text='<%# Bind("sof_softwareName") %>'
CommandName="sofID" OnCommand="GetSoftwareModal" CommandArgument='<%# Eval("sof_id") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sof_platform" HeaderText="Platform" ReadOnly="True" SortExpression="sof_platform" />
</Columns>
<HeaderStyle CssClass="gridHeader" />
<PagerSettings Position="Bottom" />
<PagerStyle HorizontalAlign="Right" VerticalAlign="Middle" CssClass="gridPage" />
<AlternatingRowStyle BackColor="White"></AlternatingRowStyle>
</asp:GridView>
And below is the code for the ModalPopupExtender
<ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="sofLink"
PopupControlID="ModalPanel" DropShadow="true" Drag="true" OkControlID="OKButton" />
<asp:Panel ID="ModalPanel" runat="server" Width="500px" style="width: auto; height: auto;" CssClass="modalPopup">
<asp:Label ID="softwareTitle" Font-Bold="true" Font-Size="Medium" runat="server" Width="100%" style="text-align: center;" /><br /><br />
<asp:Literal ID="litSoftware" runat="server"></asp:Literal>
<asp:Button id="OKButton" runat="server" Text="Close" style="position: relative; right: 0px; width: 100px;" />
</asp:Panel>
<asp:ScriptManager ID="asm" runat="server" />
And below is the code for the animation
<ajaxToolkit:AnimationExtender ID="popupAnimation" runat="server"
TargetControlID="sofLink">
<Animations>
<OnClick>
<Parallel AnimationTarget="ModalPanel"
Duration="0.3" Fps="25">
<FadeIn />
</Parallel>
</OnClick>
</Animations>
</ajaxToolkit:AnimationExtender>
Thanks for any help you can provide.
The TargetControlID (as far as I am aware) should be a control in the popup panel itself, not in the grid control. When I use the ModalPopupExtender I usually use an asp:Button with 'display:none' as the TargetControlID. Eg,
<ajaxToolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btnPopup"
PopupControlID="ModalPanel" DropShadow="true" Drag="true" OkControlID="OKButton" />
<asp:Panel ID="ModalPanel" runat="server" Width="500px" style="width: auto; height: auto;" CssClass="modalPopup">
<asp:Button id="btnPopup" runat="server" style="display:none" />
In the code-behind you have to control the showing and hiding of the control base on an event, eg, GetSoftwareModal. You will also also to bind what you need if applicable.
Hope that helps.
You could use a hidden button and use it's ID as TargetControlID of the ModalPopupExtender.
<asp:Button id="btnShowPopup" runat="server" style="display:none" />
Then you can call the button's click clientside if you want to show the popup immediately without postback in the follwoing way:
<asp:LinkButton ID="sofLink" runat="server" OnClientClick="javascript:document.getElementById('btnShowPopup').click();return false;">LinkButton</asp:LinkButton>
I tried however my animation doesn't display.
I add databind into LinkButton:
<asp:LinkButton ID="sofLink" runat="server" OnClientClick="javascript:document.getElementById('DetailView1').databind();document.getElementById('btnShowPopup').click();return false;">LinkButton</asp:LinkButton>
I think because of databind of DetailView1, it need get data from database. If DetailView1 doesn't bind, the animation display normal.

Why updatepanel triggers another updatepanel?

I have two update panels at my ajax page. This is first time I'm using updatepanel and I don't know what is wrong. I think only btnFilter's Click event must trigger the second update panel's content but changing combo values (which also hides/unhides btnFilter button) makes second updatepanel change content (at least I see transferred data with firebug & second updatepanel blinks sometimes). Online here.
<asp:UpdatePanel ID="upComparison" runat="server">
<ContentTemplate>
Brand:
<asp:DropDownList ID="ddlBrands" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlBrands_SelectedIndexChanged"
AppendDataBoundItems="true">
<asp:ListItem Value="" Text="Please select a brand..." />
</asp:DropDownList>
<asp:Panel ID="pModels" runat="server" Visible="false">
Model:
<asp:DropDownList ID="ddlModels" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlModels_SelectedIndexChanged" />
</asp:Panel>
<asp:Panel ID="pButton" runat="server" Visible="false">
<asp:UpdateProgress ID="upMain" runat="server" DisplayAfter="100">
<ProgressTemplate><img src="/Assets/Images/loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Button ID="btnFilter" runat="server" Text="Filter"
OnClick="btnFilter_Click" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upList" runat="server">
<ContentTemplate>
<asp:Repeater ID="rProducts" runat="server">
<ItemTemplate>some code here</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
By default, every UpdatePanel will be refreshed during every asynchronous postback.
To change this behavior, set the UpdateMode property to Conditional.

Categories