ScriptManager and EnablePartialRendering - asp.net

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.

Related

aspx FileUpload empty when used with UpdateProgress indicator

The FileUpload and Button controls work fine by themselves. When I add the rest of the code as seen below for the UpdateProgress indicator, the FileUpload control is empty (PostedFiles.Count = 0) after selecting files and btnUpload. 'Loading...' displays ok. Something seems to reset FileUpload. Any ideas?
<asp:FileUpload ID="fuImageUploader" runat="server" AllowMultiple="True" BorderStyle="Inset" BorderWidth="1px" Font-Size="Larger" Height="24px" oninput="fuImageUploader_Click()" ToolTip="Select image file" ValidateRequestMode="Disabled" Width="391px" />
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Button ID="btnUpload" runat="server" Height="26px" Text="Upload" Width="86px" OnClick="btnUpload_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" id="PageUpdateProgress" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
Loading...
</ProgressTemplate>
</asp:UpdateProgress>

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>

How to use multiple ajax calendars in a single page

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>`

Alternative to Postback on asp.net page

I am looking for an alternative where user doesnt has to wait for postback in an asp.net page.
My situation :
I have several drop down lists on my asp.net page (11 infact) and I have a checkbox. 2 drop downs are cascading. i.e. selecting 1st drop down changes the 2nd drop down contents. I have a new option in some of the dropdowns (6 drop downs). If user chooses this option then a text box shows up with a "Add" button. Adding text to that text box and hitting "Add" adds the new value to the drop down and disappears this textbox and the button. So is it possible for using a non postback option but have the same situation going on? User does not like that the page postbacks 11 times. What is my alternative? If you need more information, please ask. Thanks
EDIT:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlCustomerContact" runat="server" DataTextField="FullName" DataValueField="Customers_SourceIDfk2" AutoPostBack="true" TabIndex="1" />
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub ddlCustomerContact_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlCustomerContact.SelectedIndexChanged
If ddlCustomerContact.SelectedIndex = 1 Then
divAddNewCustomerContact.Visible = True
Else
divAddNewCustomerContact.Visible = False
End If
End Sub
Your only real option if you don't want standard postbacks would be AJAX. There are numerous frameworks available, so you can use the Microsoft framework (bundled in 3.5+) or jQuery (also bundled in VS 2010+, I believe).
There are other frameworks available, but those two are going to be the most tightly integrated. Other frameworks will require a little more work to implement.
This is how I use an update panel for a widget that I created.
<asp:DropDownList ID="ddlPayrollStores" runat="server" OnSelectedIndexChanged="ddlPayrollStores_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanelPayroll" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlPayrollStores" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
<ContentTemplate>
<div class="dragbox-content">
<asp:Label ID="lblLabelHours" runat="server" Text="Reg Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelOverTime" runat="server" Text="Total Overtime Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalOvertime" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelHoliday" runat="server" Text="Total Holiday: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHoliday" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelVacation" runat="server" Text="Total Vacation: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalVacation" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lbllableTotalHours" runat="server" Text="Total Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalStoreHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelPay" runat="server" Text="Total Pay: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalPay" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="align-content: center">
<asp:LinkButton ID="lbDetailed" runat="server" Text="Detailed Report" PostBackUrl="~/Reporting/Payroll/StorePayroll.aspx"></asp:LinkButton>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
This is for a payroll widget that shows the store's total payroll. So when I select which store I want to see with the drop down, the update panel will post back without posting back the entire page. In my case, it will just display numbers as labels. Hopefully this leads you in the right direction and possibly clears it up a bit.

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