Refresh asp:UpdatePanel when navigating to other panels in the same container - asp.net

First off, I'm brand new to ASP.NET so I hope I use the correct terminology. I think that what I have is several asp:UpdatePanels in one ajaxToolKit:TabContainer. One panel has some checkboxes one it, here is the first part of the code for it:
<ajaxToolKit:TabPanel ID="MedicaidDataSubTabReadyToBill" runat="server" HeaderText="Ready To Bill">
<ContentTemplate>
<asp:Label ID="lblReadyToBillMessage" runat="server" Font-Size="X-Small" ForeColor="Red" ></asp:Label>
<asp:UpdatePanel ID="MedicaidDataReadyToBillPanel" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:RegularExpressionValidator ID="regSchoolYear" runat="server"
ControlToValidate="uxMedicaidDataReadyToBill_SchoolYear" ErrorMessage="*invalid school year format." Font-Size="X-Small"
ValidationExpression="^\d{4}$">
</asp:RegularExpressionValidator>
This panel loads some checkboxes, some checked and some not, then I go to another panel in the same container and upload an excel file that should make changes to the database that should affect the check boxes on the first panel. Problem is, when I navigate back to the first panel the changes don't reflect. In order for the changes to show I have to refresh the whole page. Is it possible to have this first panel show the changes without having to refresh the whole page? If so how do I do that? If more code is needed to answer this please let me know. Thanks in advance.

The basic way to update an update panel is simple
MedicaidDataReadyToBillPanel.Update();
When your code that uploads and does db stuff is finished, add that line. Assuming everything else is working, that's all you need.

Related

Create a web page as 2 parts

I want to develop a registration form with 2 panels. One panel is personal information and another is address details. In these panels the user fills in all details of personal information and after completion of this, the user clicks on Add Address Details. If the user clicks on that, the second panel should be visible without page refresh. How can I accomplish this?
you would use javascript to append the append the second form to to the div of the first form. Or however you have it setup. So in jquery it would look something like this:
<script type="text/javascript">
$('#buttonid').click(function() {
$('#divid').append("<form><input />etc etc etc</form>");
});
</script>
You should use the ASP.NET Wizard control. It is the perfect tool for these scenarios. Scott Gu has a post with some links explaining how to use it. I recommend you look at it.There's a video linked that walks you through a full example.
I don't know, but hiding/showing panels based on certain conditions on the same page feels inelegant and hacky to me.
You should look into using an UpdatePanel. Within there you could place to Panels with different form information. Tie in a few button clicks and hide/show the different panels.
Edit with a simple example
<asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id="upnl" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnl1" runat="server">
<!--personal info-->
<asp:Button ID="btn1" runat="server" Text="this button could validate personal info, hide pnl1 and show pnl2" />
</asp:Panel>
<asp:Panel ID="pn2" runat="server" Visible="false">
<!--address info-->
<asp:Button id="btn2" runat="server" Text="this button could validate address information and finally submit the form." />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Asp Focus on input jumping bug

I've got a web form using asp.net. In this form I have a lot of inputs.
For one of the drop downs whenever you press it, the focus jumps to the next text box.
This is in a update panel, because there is some server side work required for filtering, hiding, etc.
If the User chooses Australia from visaType_filter then it hides visaType_dd and shows visaType_tb. If they choose NZ its the other way around.
Now my question:
Is there a bug or something that makes focus jump off of a drop down when you click on it to go to the next input (or control)?
Code:
<fieldset>
<asp:UpdatePanel ID="visaTypeUpdatePanel" runat="server">
<ContentTemplate>
<label>Visa Type Number</label>
<label>
<asp:DropDownList ID="visaType_filter" runat="server" Width="40%" OnSelectedIndexChanged="visaType_filter_SelectedIndexChanged" AutoPostBack="true"/>
<asp:TextBox ID="visaType_tb" runat="server" Width="40%" OnTextChanged="visaType_tb_blur" AutoPostBack="true"/>
<asp:DropDownList ID="visaType_dd" runat="server" Width="40%"/>
<asp:Literal ID="visaType_literal" runat="server" />
</label>
</ContentTemplate>
</asp:UpdatePanel>
</fieldset>
<fieldset>
I resolved my problem by using jQuery and Ajax in place of UpdatePanels.
AFAIK, when UpdatePanel gets triggered, the focus does not get maintained. So ideally, you shouldn't be getting any focus at all.
Regardless of reason, you can work-around the issue using ScriptManager.SetFocus method to maintain focus on the drop-down.
You can also have client side solutions for maintaining focus - they essentially work by hooking into AJAX requests to remember the focused control before update panel is triggered and then restoring it back when update panel post-back is completed: see this link for one such solution.

Checkbox in GridView not persistent ASP.NET

I am having issues with this GridView. I update it in design mode, and the update does not make it to the code behind section. For example, I add field "xyz". Gridview says "xyz" fields exist in design mode. In code-behind, it does not exist. when you view the page in browser, ofcoure "xyz" field is not shown. After refresh, even the gridview looses this field in design mode. So ok I got around this problem and managed to add a template field which is now working.
Now the problem is, the checkbox that I added in one of the column is not persistent. I have a button which works on the selected values of checkboxes but each time I click the button, the page refereshes and all the checked values are lost (checked values becomes unchecked).
Does anyone has any idea?
Want to mention, I am working with a bit messy code. But dont want to change a lot at this time.
<asp:TemplateField HeaderText="All" >
<HeaderTemplate>
<asp:CheckBox ID="chkAll" runat="server" name="chkAll" />
</HeaderTemplate>
<EditItemTemplate>
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkRow" runat="server" />
</ItemTemplate>
</asp:TemplateField>
This took me a couple of days to figure out myself. Since my code was quite messy, it was hard to troubleshoot.
I put in some code in page_load default event that finally fixed. Don't know if I was putting code in the wrong place first. It definitely took some time though.

Delete from grid asp.net

i have this template field inside a gridview.
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:ImageButton ID="ImageButton2" ImageUrl="~/images/DeleteRecord.gif" runat="server"
OnClientClick="return ConfirmacionBorrarClausula();" CommandName="BorrarClausula" CommandArgument='<%#Eval("ClausulaID")%>' OnCommand="gvClausulas_OnRowDeleting" CausesValidation="false"
</ItemTemplate>
</asp:TemplateField>
I have another one in the same page but in a different gridview, almost exactly like this one but the second one isnĀ“t working.
So i have two gridviews each one with a template field like the one here, one onRowDeleting working perfectly, the other one not working at all, when i click it, it asks for confirmation (javascript function) but when i click ok to delete, the grid loses it data and the page fires all the validators.
Thank you for your time.
Make sure the control IDs are set right. And Ispostback the control level set to true. And also Try deleting the control and add it again some time that might help. Try add it from design view.
i manage to solve it, the problem was the second gridview was losing its data on the pageload, i managed that but only with the first gridview.

How do I develop an online survey application?

I want to develop application that contain number of question with independent radiobuttonlist which contain three option Yes, No, Unsure.
Daily visitors comes on the site & reply to the question. Also to show addition of the Yes, NO & Unsure in front of each question.
Please give me idea how to do such functionalty.
Regards,
Girish
Quickest and easiest way would be to piggy-back on an existing site.
http://www.polldaddy.com/ will allow you to embed polls in your own site
This is a very vague question and probably won't get much of an answer.
What technology do you want to use, .Net, Java. PHP etc, what resources do you have available?
Essentially you need some sort of database to store the questions and answers in and a front end web application built in whatever technology you decide on (as stated .net, Java or PHP are probably the most common).
Create a custom control that uses an Update Panel. Inside the update Panel you will have two PlaceHolders - 1 for your questions and 1 for your results. Hide the results placeholder by default. Once the radiobutton (OnSelectedIndexChanged) is selected, cause a postback and calculate the results. In the same Postback method, hide the Question placeholder and show the results placeholder with the calculated results.
Your page could look like this:
<UpdatePanel ID="upPanel" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="plcQuestion" runat="server">
Have you ever written asp.net code?
<asp:RadioButtonList ID="radList" AutoPostBack="true" OnSelectedIndexChanged="doStuff">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
<asp:ListItem>Unsure</asp:ListItem>
</asp:RadioButtonList>
</asp:PLaceholder>
<asp:PlaceHolder ID="plcAnswers" runat="server" Visible="false">
Results:
Yes: <asp:Label ID="lblYesResults" runat="server" />
No: <asp:Label ID="lblNoResults" runat="server" />
Unsure: <asp:Label ID="lblUnsureResults" runat="server" />
</asp:PLaceholder>
</ContentTemplate>
</UpdatePanel>
Then, on your "doStuff" method, just save the results and populate whatever result display you are going for. Hope this helps!

Resources