I have a strange problem on an aspx page. In short, I have 3 radio buttons and a table on the page. When the user activates the middle radio button two text boxes and a button is shown to the user. The button serves as a way to post back the page. Anyway, the postback should be only a partial postback. Everything works fine in IE but in Firefox I found out that if I click outside of the two text boxes and then hit the refresh button, the whole page is posted back instead of a partial postback. If I select a date from the two text boxes and don't get the cursor out of one of the text boxes and then hit the button, only a partial post back is performed, which is what I want. The question is, how could I resolve this issue with Firefox ?
The page basically looks like this:
<asp:RadioButtonList>
<asp:ListItem Value="1" />
<asp:ListItem Value="2" />
<asp:ListItem Value="3" />
<asp:RadioButtonList>
<div>
...
<asp:TextBox />
...
<asp:TextBox />
...
<asp:Button ID="refreshButton" />
</div>
...
<asp:UpdatePanel>
<ContentTemplate>
<GridView ... />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="filterRBL"
EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger
ControlID="numberOfRecordsPerPageDDL"
EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger
ControlID="refreshButton"
EventName="Click" />
</Triggers>
</asp:UpdatePanel>
Thanks in advance.
You may need to put the group of controls into a <asp:Panel> tag and/or change the UpdateMode="Conditional" on your UpdatePanel tag
Related
I have 2 asp dropdown controls and an asp grid control in an Updatepanel. Update Panel is set properties as UpdateMode="Conditional" ChildrenAsTriggers="true".
On change event of both dropdown I am calling a method which fetches data from SQL Table and binds to grid control. This works fine till data is less. Whenever I select a value from dropdown for which data is around 900+ records, it binds data to grid without any error. But doesn't trigger any other dropdown change event.
<asp:UpdatePanel ID="uPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:DropDownList ID="ddldept" runat="server" OnSelectedIndexChanged="ddldept_SelectedIndexChanged"
AutoPostBack="True"/>
<asp:DropDownList ID="ddlYr" runat="server"OnSelectedIndexChanged="ddlYr_SelectedIndexChanged"
AutoPostBack="True"/>
<asp:DataList ID="gvData" runat="server" OnItemDataBound="gvData_ItemDataBound">
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddldept" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
What could be the reason of event stops triggering?
EDIT 1:
Found error in console:
POST http://devserver:1111/mysite/SitePages/Main.aspx 500 (Internal Server Error)
ScriptResource.axd?d=FcwEEmnie6xhah_BvAg_MQP-cTp24dyFdRx9c2UxylFp5s8-W18rfLHBOC-uoS-F5J3jgyRFMZWkZS…:4803
Found the answer.
Just had to add following entry to web.config.
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="3001" />
</appSettings>
Started working
I am writing an asp.net website and im trying to use the asp.net button. Though the code behind is correct and i used the update panel, every time i click on the button the code behind does not execute and instead of that the page reloads. Can you please help me?
Here is the part of the code i use the button:
<div class="row">
<div class="col-lg-8 col-md-offset-4 padding-left-0 padding-top-20">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Button class="btn btn-primary" ID="btnLogin" runat="server" Text="Log in" OnClick="btnLogin_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnLogin" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
Finally solved it, somewhere in the master page there was an "action" field in the form, i removed it and its all okay now. Thanks Rumen for the help
I'm using an ASP.NET Accordion control with lots of panes for a data entry form. Within several of the panes are some UpdatePanels, so that some controls within those panels can be enabled or disabled to prevent users from entering values into fields which are precluded by values they've entered elsewhere.
It all works fine, but for some reason, on about half of the occasions where an UpdatePanel postback is triggered (by a specified AsyncPostBack Trigger), the first pane of the Accordion momentarily expands and collapses. This gives that horrible 'flashing' experience you get when a page does a full postback, which is exactly what I'm trying to avoid by using UpdatePanels.
The problem doesn't seem to relate to the contents of the first pane - I tried completely deleting the first pane, so that the second pane became the first, and the same thing happens.
Anybody got any ideas why this is happening and how to fix it?
UPDATED WITH CODE
This is an example of one of the panels. Don't be too offended by the use of a table - it's an actual table, I'm not just using it for layout purposes!
<tr class="grouprow">
<td>Transportation</td>
<td><asp:RadioButtonList ID="rblTransportation" runat="server" RepeatDirection="Horizontal" SelectedValue='<%# Bind("AdmissionTransportation")%>' AutoPostBack="true"
OnSelectedIndexChanged="rblTransportation_SelectedIndexChanged" >
<asp:ListItem Text="Unknown" Value="" />
<asp:ListItem Text="Yes" Value="True" />
<asp:ListItem Text="No" Value="False" />
</asp:RadioButtonList></td><td></td>
</tr>
<tr class="grouprow">
<td>Transportation Duration</td>
<td><asp:UpdatePanel ID="updTransportationHours" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rblTransportation" EventName="selectedindexchanged" />
</Triggers>
<ContentTemplate>
<asp:TextBox ID="txtTransportationHours" runat="server" Text='<%# Bind("AdmissionTransportationHours")%>' CssClass="tinytextbox" />
<label class="unit">Hours</label>
<asp:RegularExpressionValidator ID="revTransportationHours" runat="server" ControlToValidate="txtTransportationHours" ValidationExpression="\d{1,3}(\.\d{1,2})?"
ValidationGroup="Past30Days" ErrorMessage="Invalid format for Transporation Duration. Please enter in format 'xxx.xx', e.g. '3.25'" Display="Dynamic"
CssClass="error" >*</asp:RegularExpressionValidator>
<asp:RangeValidator ID="rvTransportationDuration" runat="server" ControlToValidate="txtTransportationHours" CssClass="error" ValidationGroup="Past30Days" type="Double"
ErrorMessage="The Transportation Duration cannot be more than 100" MinimumValue="0" MaximumValue="100" >*</asp:RangeValidator>
</ContentTemplate>
</asp:UpdatePanel></td><td></td>
</tr>
I believe you need your rblTransportation RadioButtonList wrapped in an UpdatePanel as well.
Since that control isn't in an UpdatePanel, it causes a full postback.
The answer is gloriously simple, though I'm too tired to figure out why it works just now. I simply need to set ClientIDMode = AutoID on the RadioButtonLists and CheckBoxLists and they now trigger an asynchronous postback rather than a full one. They don't need to be within their own UpdatePanels either.
I got the answer from this SO question.
Can you try <asp:blablacontrol style="Display:none;"> </asp:control>
modalpanels has same problem and this codes solved my problem
Our problem/question revolves around an upload control that loses the selected file (goes blank) when a postback control is used (in this case, the dropdown list posts). Any insight into what we are doing wrong or how we can fix this? Below is our code and a summary of the problem.
Any help would be greatly appreciated.
Thank you!
<asp:updatepanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="row">
<asp:DropDownList runat="server" AutoPostBack="true" ID="CategorySelection" OnSelectedIndexChanged="CategorySelection_IndexChanged" CssClass="drop-down-list" />
</div>
<div id="SubCategory" class="row" runat="server" visible="false">
<asp:DropDownList runat="server" ID="SubCategorySelection" CssClass="drop-down-list" />
</div>
<div class="row">
<asp:FileUpload runat="server" ID="FileUpload" CssClass="file-upload" />
</div>
<div class="row">
<asp:Button ID="submit" runat="server" Text="Submit" CssClass="button" OnClick="submit_ButtonClick" />
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="submit" />
</Triggers>
</asp:updatepanel>
In this form we have 2 DropDownList, 1 FileUpload and 1 submit button. Every time that the user selects one category, the subcategories are loaded (AutoPostBack=”true”).
The primary user flow works fine: User selects one category, subcategory and selects a file to be uploaded (submitted). HOWEVER, if the user selects a file first, and then selects a category, the screen will do a partial refresh and the selected file will disappear (field goes blank). As a result, the user needs to select the file again. This causes an issue because the fact that the file is no longer selected can easily be overlooked.
Seems straighforward --- but causing us a lot of grief. Any experts out there that can help?
BIG thanks!
That is the behavior of the input type=file i.e. it can't be pre-populated. Move the FileUpload outside of the UpdatePanel. In your markup, you could move both FileUpload and the submit Button outside of the UpdatePanel.
I have a linkbutton inside a updatepanel and when the update panel does a partial page rendering, the linkbutton disappears.
<asp:UpdatePanel ID="up" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="drp" runat="server" AutoPostBack="true" CausesValidation="true">
<asp:ListItem Text="" Value="" />
<asp:ListItem Text="a" Value="a" />
<asp:ListItem Text="b" Value="b" />
<asp:ListItem Text="c" Value="c" />
</asp:DropDownList>
<asp:LinkButton ID="link" Text="abc" runat="server" />
</ContentTemplate>
I think that is because the link button is rendered using a script and that script is not run after the post back.
How do I overcome this?
Thanks,
Eric
Thank you to all considered my question.
I found out the reason is on our side. Apparently in our company we have overwritten the rendering of LinkButton in order to support browsers without javascript, in which case the LinkButton will be rendered as a normal input button. This is done using the and block within HTML. The script that generate the anchor tag is not run after partial page postback.
I am looking at a fix for it now.
Eric