How to use multiple ajax calendars in a single page - asp.net

I am trying to use a calendar to insert dates. Unfortunately, I have to use more than one calendar. For extracting the date from the calendar, I am using Ajax toolkit
`<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
</cc1:ToolkitScriptManager>
<asp:TextBox ID="DateOfPurchase" runat="server" Height="30px" ReadOnly="true" Width="262px"></asp:TextBox>
<asp:ImageButton ID="imgPopup" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="DateOfPurchase"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`
So whenever I add more than one
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
</cc1:ToolkitScriptManager>
my program shows error.
And if I use Only one ToolkitScriptManager and multiple Ajax calendar controls, clicking on only one image button for displaying the calendar, all the calendars,on the page, pops up.

Each CalendarExtender must have its own ID
<asp:ImageButton ID="imgPopup1" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup1" runat="server" TargetControlID="DateOfPurchase1"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`
<asp:ImageButton ID="imgPopup2" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar2" PopupButtonID="imgPopup2" runat="server" TargetControlID="DateOfPurchase2"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`

Related

Unable to resolve ASP.NET error when starting web app

Here is my code:
<ajaxToolKit:TabPanel ID="mainTabMedicaidData" runat="server" HeaderText="Medicaid Data">
<ContentTemplate>
<ajaxToolKit:TabContainer ID="MedicaidDataSubTabContainer" runat="server">
<ajaxToolKit:TabPanel ID="TabPanel1" runat="server" HeaderText="Search">
<ContentTemplate>
<asp:UpdatePanel ID="MedicaidDataPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<div class="formRow">
<asp:Label runat="server" ID="uxMedicaidData_StudentNumberLabel" AssociatedControlID="uxMedicaidData_StudentNumber">
Student ID:
</asp:Label>
<asp:TextBox runat="server" ID="uxMedicaidData_StudentNumber" MaxLength="30" Width="80px"></asp:TextBox>
<asp:Label runat="server" ID="uxMedicaidData_SchoolYearLabel" AssociatedControlID="uxMedicaidData_SchoolYear">
School Year:
</asp:Label>
<asp:TextBox runat="server" ID="uxMedicaidData_SchoolYear" MaxLength="30" Width="50px"></asp:TextBox>
<asp:Label runat="server" ID="uxMedicaidData_CategoryLabel" AssociatedControlID="uxMedicaidData_ddCategory">
Category:
</asp:Label>
<asp:DropDownList ID="uxMedicaidData_ddCategory" runat="server"></asp:DropDownList>
<asp:Button runat="server" ID="MedicaidData_Search" Text="Search" width="100px" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
I know that the snippet does not have a closing tag for some of the tags at the beginning of the snippet. The reason I left them out is because there is a lot of code between them and their closing tags. Besides, from what I can tell my problem is with the with either 1 line or another in this code snippet.
When I try to compile this to run the web app I get the following error:
TabContainer cannot have children of type
'System.Web.UI.WebControls.Button'.
The error highlights this line:
<ajaxToolKit:TabContainer ID="MedicaidDataSubTabContainer" runat="server">
But because the error states there can't be a button in the container I'm wondering if this line has something to do with it:
<asp:Button runat="server" ID="MedicaidData_Search" Text="Search" width="100px" />
I've looked at quite a few solutions online and they all say that the container needs runat="server" and an ID. As you can see both of these lines have those parts. Anyone have an idea of another solution I can try? Thanks in advance.
I think it's because you have content outside of a content template.
The outline should be
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
<ContentTemplate>
Content1
</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="TabPanel2">
<ContentTemplate>
Content2
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>

Data Pager + Update Panel + list view

I need help, I have a DataPager inside the update panel and and working well, but when I refresh page or going on back button form some other page DataPager reset always to the first page.
For example if I was on the tenth page and refresh page, data pager reset to first.
Is there any way to keep the current page on data pager?
My code is:
<asp:SqlDataSource ID="SqlDataSource1" EnableCaching="True" CacheDuration="4000" CacheExpirationPolicy="Sliding"
runat="server" ConnectionString="<%$ ConnectionStrings:blabla %>" SelectCommand=""></asp:SqlDataSource>
<asp:UpdatePanel ID="UpdatePanelnajgornji" runat="server" >
<ContentTemplate>
<asp:ListView ID="ListView1" runat="server" ondatabound="ListView1_DataBound" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" Visible='<%# !(Eval("Slika") is DBNull) %>' runat="server" NavigateUrl='<%# Eval("Link") %>' title='<%# Eval("Naslov") %>'>
<asp:Image ID="Image1" runat="server" AlternateText='<%# Eval("Naslov") %>' ImageUrl='<%# Eval("Slika") %>' /></asp:HyperLink>
</ItemTemplate>
</asp:ListView>
<br />
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1">
<Fields>
<asp:NextPreviousPagerField />
</Fields>
</asp:DataPager>
</ContentTemplate>
</asp:UpdatePanel>
Browser refresh creates new objects (and thus clears the state of the DataPager). You need to save the current page either in the Session or the ViewState, then initialize the control using those values if they exist in the codebehind. Store the values in an unload event listener.

Why can I not unregister my UpdatePanel when it was not registered with the ScriptManager?

I am using the modal pop up in the code below. I am getting the following error:
Cannot unregister UpdatePanel with ID 'updatePnl' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
Parameter name: updatePanel
What could be causing this?
Here is my code:
<telerik:GridTemplateColumn HeaderStyle-Width="20%" HeaderText="See Your Assessment">
<ItemTemplate>
<asp:Button CommandName="Show" OnClick="grdMasterbtnClick" CommandArgument='<%#Eval("SurveyClientID")%>'
ID="btn" runat="server" Text="Your Assessment" />
<cc1:ModalPopupExtender CancelControlID="btnCancel" PopupControlID="modelPopUp" ID="ModalPopupExtender1"
runat="server" TargetControlID="imgClientFreeEval">
</cc1:ModalPopupExtender>
<asp:UpdatePanel ID="updatePnl" runat="server">
<ContentTemplate>
<asp:Panel ID="modelPopUp" runat="server" Visible="false" BackColor="AliceBlue">
<p>
These items will be permanently deleted and cannot be recovered. Are you sure?
</p>
<asp:Button ID="btnOk" Text="OK" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<HeaderStyle Width="20%"></HeaderStyle>
</telerik:GridTemplateColumn>

ScriptManager and EnablePartialRendering

I have a page that uses ajax scripmanager > progressupdate so I can display the user a message of "Loading, wait..". Now, my question is the following. I have the EnablePartialRendering set to true, mainly because if I set it to false my panel with the loading stuff doesn't display.
When is set to true, then if I want to set the text and visibility on a row that is normally set to visible=false, it just doesn't happen. My row doesn't show.
My "Loading" message will only display if a stored procedure exist, if it doesn't I just need to let the user know.
Any suggestions?
Here is some code from my .aspx page
.
.
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:Panel ID="pnlUpdate" runat="server" >
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" >
<ProgressTemplate>
<div id="progressBackgroundFilter"></div>
<div id="processMessage" align="center" style="color:#cc0000"> Please, wait while processing...<br /><br />
<asp:Image ImageUrl="images/loading.gif" runat="server" ID="loading_gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Panel>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow ID="Row_Error" Visible="false">
<asp:TableCell CssClass="GVI">
<asp:Label ID="labelError" runat="server" Text=""/> </asp:TableCell>
<asp:TableCell CssClass="GvItmR">
<asp:HyperLink ID="HyperLink2"ForeColor="Green" Text="Go Back" NavigateUrl="~/Menu.aspx" runat="server"/>
</asp:TableCell>
</asp:TableRow>
The Row_Error row is where I want to display a message.

Update Panel not working correctly?

I have added two update panels to my page. I'm trying to update the first panel but not the second. The second panel contains validation controls which seem to be kicking in no matter what I try.
Code
<asp:ToolkitScriptManager runat="server" ID="ScriptManager" />
<asp:UpdatePanel ID="updatePnl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:label ID="NoConsignments" runat="server" ForeColor="red" />
<br />
<asp:TextBox ID="StartDate" runat="server" /> <asp:TextBox ID="EndDate" runat="server" /> <asp:Button ID="Dates" OnClick="btDates" runat="server" Text="Search" />
<asp:calendarextender ID="Calendarextender2" targetcontrolid="StartDate" Format="dd/MM/yyyy" runat="server"></asp:calendarextender>
<asp:calendarextender ID="Calendarextender3" targetcontrolid="EndDate" Format="dd/MM/yyyy" runat="server"></asp:calendarextender>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Dates" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
I've left out some of the middle code of there is alot. If you would like any more code please let me know.
Am I missing something? or is this not the way that update panels should be used?
Thanks you so much for any help you can provide
I would guess that the validation controls in the second UpdatePanel are firing their client-side validation methods (so the update panel isn't posting back, which is correct).
You might be able to get around this by using the ValidationGroup property - assign the validation controls in the first update panel to one validation group (e.g. "ValidationGroupA"), and the validation controls in the second update panel to another validation group.
I haven't used UpdatePanels for a while, and you haven't included the mark up for the validators in the second panel.
However it looks to me like you might not be adding groups to your validation see this tutorial
e.g.:
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="First"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ValidationGroup="First" ErrorMessage="TextBox1 should not be blank"
ControlToValidate="TextBox1"/>
<asp:Button ID="Submit1" runat="server" ValidationGroup="First"
Text="Submit 1"/>
<asp:TextBox ID="TextBox3" runat="server" ValidationGroup="Second"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage=" TextBox3 should not be blank"
ControlToValidate="TextBox3" ValidationGroup="Second"/>
<asp:Button ID="Submit2" runat="server" ValidationGroup="Second"
Text="Submit 2"/>
</div>
</form>
</body>
Hope this helps and I haven't missed the point.
You have to specify ValidationGroups for your Buttons and Validators, f.e. Panel1 for your Searchbutton and Panel2 for your Validators in second UpdatePanel.
<asp:Button ID="Dates" ValidationGroup="Panel1" runat="server" Text="Search" />
....
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ValidationGroup="Panel2" ErrorMessage="RequiredFieldValidator"
ControlToValidate="TextBox1" />
</ContentTemplate>
</asp:UpdatePanel>

Resources