Hidden Field In Update Panel Doesn't Get Updated
Feb 8, 2010
I am using C# for my programming. I am facing issue, that my hidden variable value is not being updated when it is in update panel. Please see below code for aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
</asp:Timer>
<input type="hidden" runat="server" id="hidCurrentDate" value="" />
<input type="hidden" runat="server" id="hidTripIds" value="" />
<input type="hidden" runat="server" id="hidTripDetails" value="" />
<asp:UpdateProgress ID="uprogTrips" runat="server">
<ProgressTemplate>
<span style="display: block; text-align: center">
<p style="font-family: Verdana; font-size: larger; font-weight: bold;">
<img src="../../Images/ajax-loader.gif" alt="Processing..." /><br />
<br />
Processing...</p>
</span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvAllTrips" runat="server" OnRowDataBound="gvAllTrips_RowDataBound"
OnPageIndexChanging="gvAllTrips_PageIndexChanging" AllowPaging="true" AutoGenerateColumns="false">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="35" Position="TopAndBottom" />
<PagerStyle CssClass="GridPager" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
<asp:AsyncPostBackTrigger ControlID="ddSortBy" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="ddFilterBy" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="cbPageOptions" EventName="CheckedChanged" />
</Triggers>
</asp:UpdatePanel>
and below is the code where I am trying to update one of the hidden field with my CS code. Interesting, when I am trying to debug its showing all the values, however when I see it f on page source it doesn't give any value. Here is my aspx.cs code:
protected void Timer1_Tick(object sender, EventArgs e)
{
DataTable dtTrips = null;
WEX.Prototype.Data.TripDA tripDA = new WEX.Prototype.Data.TripDA();
string tID = hidTripIds.Value;
string[] tripIDs = new string[1000];
tripIDs = tID.Split(',');
foreach (string tripID in tripIDs)
{
TripSummaryBO tripSummaryBO = tripDA.getTripSummary(Convert.ToInt32(tripID));
if (tripSummaryBO.tripLastEditedOnDate > Convert.ToDateTime(hidCurrentDate.Value))
{
WEX.Prototype.Service.WSProxies WSProxies = new WEX.Prototype.Service.WSProxies();
dtTrips = WSProxies.Build();
Session["AllTrips"] = dtTrips;
dtTrips = (DataTable)Session["AllTrips"];
if (dtTrips != null)
{
if (cnt==0)
{
hidTripDetails.Value = ("Trip name-" + tripSummaryBO.tripName + " was modified by user " + tripSummaryBO.tripLastEditedBy);
}
else
{
hidTripDetails.Value = hidTripDetails.Value + " <br/> " + ("Trip name-" + tripSummaryBO.tripName + " was modified by user " + tripSummaryBO.tripLastEditedBy);
}
BuildGridViewControl(dtTrips);
cnt = cnt + 1;
}
}
else
{
//upTripsGrid.Triggers.Clear();
PageInit();
}
}
}
View 1 Replies
Similar Messages:
Feb 29, 2012
I have 2 text controls one visible & other hidden & a button1 wuth client click  in update panel
when the user enters the value in visible text control & clicks button1 the value is passed to the hidden field & i get value in the hidden field
outside the update panel there is one more command button with server side click event
on command button click i need to get values of the hidden field in server side which currently i am getting blank
I even tried by putting the command button in another update panel
but still i get blank
View 1 Replies
Feb 14, 2011
I'm using a hidden field to store a value in an asp.net page. Basically I set the value of the hidden field whenever a value on the form is changed i.e. first name, date etc. The field is on a webform that has a master page and is in the content section:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:HiddenField ID="hdnDirtyFlag" runat="server" Value='false' />
I change the value of the field in javascript by calling a function whenever an onchange event fires in other controls on the web form:
<asp:TextBox CssClass="niceInput" ID="tbFirstName" runat="server" MaxLength="40" Width="150" onchange='SetHiddenVariable();'></asp:TextBox>
<script type="text/javascript">
function SetHiddenVariable() {
// Set the value of the hidden variable so we know a field has been updated
var hiddenControl = '<%= hdnDirtyFlag.ClientID %>';
document.getElementById(hiddenControl).value = 'true';
}
</script>
So far so good. When the page loads the hidden field value is 'false', and if I don't change any values on the webform it remains false. Whenever I do change another control the javascript function gets called and the hidden field value gets updated to 'true'. Again this is all fine.
After I submit the form and update the database, I set the hidden field value back to 'false' in the code behind:
hdnDirtyFlag.Value = "false";
But when I click another button and do a postback, the hidden field value is still at 'true'.
Can anyone explain why this is? I stepped through the code behind and immediately after changing the value I can see the value is 'false'. There is an asp:UpdatePanel on the page but the hidden field is not part of this panel.
EDIT:
This is the code I use to check the value of the field in code behind in the second postback, after it has been set to false in the last step of the first postback. The value remains at true for some reason in the second postback, after it has been set to true in javascript on the client side then set back to false in code behind as shown above:
if (hdnDirtyFlag.Value == "true")
{
UpdateSecurityObject();
}
View 2 Replies
Sep 3, 2010
I am using a update panel in my webpage. I am having a treeview in it . The css property of the Treeview before updating is different from after.
View 2 Replies
Feb 3, 2011
I have a page with 2 update panels.
Controls in the update panel holds a listview and each row here has a button. This button fires a FancyBox (modal dialog) When closing this a call to the onClosed event is triggered like here:
[Code]....
There is two of these sections one for each update panel. The problem here is that this 'Page.ClientScript.GetPostBackEventReference' actually updates the wrong update panel!It is always updating the first updatepanel on the page, and I cannot figure out why this is. The two update panels areencapsulated in its own user control, but still the first update panel is always fired.
View 1 Replies
Mar 23, 2011
I have a custom user control which contains a asp hiddenfield object. The value of this hidden field is being set using javascript and I have verified that the value is being set properly. When a postback occurs the new value is not being saved and I cannot access it in my code.
I believe the problem is because the user control is not saved in viewstate and therefore the hidden field value is not saved accross postback. How can I make the hidden field save its value? I tried accessing it from the early page cycles and still no luck.
View 4 Replies
Mar 29, 2010
I have Dropdownlist and Datalist in Usercontrol. Images in Datalist will be loaded
according to Drodownlist Selected Value.I have placed the Usercontrol in Page with Update panel. So Now Usercontrol is placed With in Update Panel.the problem is Datalist is not Updated Properly. according to the Dropdownlist Selected Value.Can any one solve this issue.
View 2 Replies
Jan 16, 2014
I have a ListView control that is inside of an update panel. I have a Button control that calls code behind when clicked and I have a trigger in the update panel that is triggered based on the click event of the button. The button that calls the code behind and inserts a record into the database works fine but I get a full page refresh and the ListView Data is not updated as expected. I then can go to another page, come back and the new data is there. I'm not sure what I missing. Please see the code below.
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:ListView ID="ListView2" runat="server" DataSourceID="sdsrcMessageComments" DataKeyNames="MessageId"
ItemPlaceholderID="PlaceHolder2" EnableViewState="False">
[code]....
View 1 Replies
Jun 22, 2010
I have a user control which has a gridview with hidden fields in some of the template columns. The grid columns are created and bound by code dynamically in each postback and not in design mode. The gridview is placed in an update panel. In my aspx page where i use the user control , there is a dropdown which fires postback and based on the selected value of the dropdown the grid data gets filtered. The dropdown in aspx is not part of any update panel.
After the postback of dropdown, the grid data gets filtered and the grid is rebound with fresh values. The values in the controls like label, button or link button are bound correctly. But the values in the hidden fields are not refreshed and always points to the values of the rows that was generated before the postback of the page (initial page load).
View 3 Replies
Jan 7, 2010
I have Gridview like this:
<asp:GridView ID="gvPartsSearchResult" runat ="server" CssClass="MRJ_TextGrid">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:RadioButton
ID="rdButton"
runat="server"
AutoPostBack ="true"
onclick="javascript:CheckOtherIsCheckedByGVIDMore()"/>
<asp:HiddenField
ID="hdnFileExtension"
runat="server"
Value ='<%#Bind("FILE_EXTENSION")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I want to read the hidden field value when the user clicks on the radio button.
View 2 Replies
Mar 26, 2010
protected void Button3_Click(object sender, EventArgs e)
{
//Create a connection to the database
MySqlConnection conn = new MySqlConnection("Database=kid07025;Data Source=195.178.228.254;User Id=kid07025;Password=********");
//open the connection
conn.Open();
//MySQL Query which updates the row where Anvandarnamn = Anvandarnamn (recieved from a cookie)
MySqlCommand cmd = new MySqlCommand("UPDATE personer SET Information=?Information,Fnamn=?Fnamn,Enamn=?Enamn,Personnr=?Personnr,Adress=?Adress,Postnr=?Postnr,Ort=?Ort WHERE Anvandarnamn=?Anvandarnamn", conn);
// Update with new text
cmd.Parameters.AddWithValue("?Anvandarnamn", Request.Cookies["Anvandarnamn"].Value);
cmd.Parameters.AddWithValue("?Information", TextBox1.Text);
cmd.Parameters.AddWithValue("?Fnamn", TextBox2.Text);
cmd.Parameters.AddWithValue("?Enamn", TextBox3.Text);
cmd.Parameters.AddWithValue("?Personnr",TextBox4.Text);
cmd.Parameters.AddWithValue("?Adress", TextBox5.Text);
cmd.Parameters.AddWithValue("?Postnr", TextBox6.Text);
cmd.Parameters.AddWithValue("?Ort", TextBox7.Text);
cmd.ExecuteReader();
conn.Close();
RefreshProfile();
}
I don't know what I am doing wrong here, but the database doesn't get updated when I press the button.
I use VS 2010, ASP.NET
View 3 Replies
Mar 14, 2011
I have a simple table with 5 text boxes, above that i have a dropdown where you make a selection, if there are any records of associated with the selection, then i display in the fields..
A while back this was working, you could make a selection and the fields were within a update panel and they were populated. But im revisiting the pages to make some updates and changes and noticing that the page no longer populates the fields when a selection is made..
Is there anyway to debug the updatepanel? I put a breakpoint in my selectedindexchanged event and my Db call is returning values and the textboxes .TEXT values are being assigned the right values in the code behind, but the fields never show up..
This page hasnt been touched since it was wworking last, so need to see how i can test / debug the update panel to determine what coudl be causing it..
[Code]....
View 3 Replies
Jun 28, 2010
I have a Required field valadator with an update panel and the following settings, also the sql to populate the ddl is at the bottom. I am looking at code I have in another website that works and its pretty much the same.
<td style="background: #dddddd; height: 19px">
<asp:DropDownList
ID="ddlFundno2" runat="server" Width="270px" />
<cc1:ListSearchExtender ID="lseFundno2" runat="server"
TargetControlId="ddlFundno2" />
</td>
<td style="width: 5px">
<asp:RequiredFieldValidator ID="reqPFN2" runat="server"
ControlToValidate="ddlFundno2"
ErrorMessage=" fund number is required"
InitialValue=""
Display="Dynamic"
SetFocusOnError="True">*
</asp:RequiredFieldValidator>
</td>
SELECT 0 as FundNo , '' as Display
UNION
SELECT DISTINCT [FundNo]
,CAST([FundNo] as Varchar(50)) + '-' + [FundName] Display
FROM [dbo].[Funds]
ORDER BY [FundNo]
View 5 Replies
Apr 29, 2010
I have a input of type file and when i try to do a Request.files when the input is wrapped in an update panel...it always returns an empty httpfilecollection. Why???
This is the codebehind: (At HttpContext.Current.Request.Files...its always 0 for the count.)
[code]....
View 1 Replies
Sep 21, 2010
I created a .NET user control to work as a DropdownCheckbox and added Jquery to give the sliding and hide effects. The code is as below:
[Code]....
This control works fine in a normal page, but once I put it inside an update panel it doesn't work. Is there a work around or simply I can't use JQuery inside update panel?
View 1 Replies
Oct 1, 2010
I have many controls like dropdown, radiobuttonlist, etc on my page and I put all these controls inside the update panel so that the page doesn't look to be posting back when something is selected. Now the working on the page is very smooth. But the session object isn't getting refreshed even if I postback to the server and as a result even if the users are working on the page they are being sent to the login screen after 20 mins.
Is there anyway where I could put all the controls in update panel and still refresh the session after any postback(dropdown selection)
View 4 Replies
Sep 5, 2010
We have two update panels on our webpage. Now first update panel is having button cancel. While second update panel is having a file upload control.
Now if the user uploads a file that is going to upload in about 2 mins, and in between, say after 30 seconds the user clicks the cancel button, the upload taking place in update panel 2 should stop.
How do we achieve this ?
View 2 Replies
Jan 28, 2011
This code works fine if i use this inside ssercontrol > panel and i have a checkboxes in table when no checkbox is checked its works fine .... but if i disabled and checked any of the textbox then this doesn't work .... in usercontrol why ? i didnt understand ..
<script type="text/javascript" language="javascript">
function checkboxChecked(){
var allInputs = document.getElementsByTagName("input");
for(var i=0; i<allInputs.length; i++) {
var chk = allInputs[i];
if(chk.type == "checkbox" && !chk.disabled && chk.checked) {
return true;
}
}
alert("OOps! You haven't selected all available checkboxes");
return false;
}
</script>
View 4 Replies
Jun 5, 2010
I have a panel withitn an updatepanel with some buttons.
When one of the buttons is pressed, I'm updating a different update panel.
The problem is that when I click the button, nothing seems to happen.
If I click the button again , then I see the first update. If I click it again, I see the second update and so on..
View 11 Replies
Oct 31, 2010
I have a asp.net page with a datalist with a textbox and a button on it, on page load the textbox gets text in it, if I change the text and press the button the text doesn't get updated.
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable table = CategoryAccess.GetProducts();
ProductList.DataSource = table;
ProductList.DataBind();
}
}
protected void btn_Click(object sender, EventArgs e)
{
string Name = textbox.Text;
CategoryAccess.UpdateProducts(Name);
}
}
View 2 Replies
Jul 23, 2010
I debugged my code and it sets the visible to true and it doesn't show up in view/source either. PnlError is the one not displaying...
[Code]....
View 8 Replies
May 16, 2010
I have one update panel inside updatepanel i have one dropdownlist .When i change dropdownlist value so as per value button1 which is out of updatepanel not visible =true or false as per dropdownlist value.
View 2 Replies
Feb 7, 2011
I am working on a web application and I want to incorporate the jQuery Highlight functionality. The way it is set up now is there is a gridview with a link button to add an entry. When you select the link button to add an entry a form appears to fill out all of the information. Once the information is filled out and the user selects "Insert" I would like to have the insert onClick function in the code behind somehow activate the jQuery Highlight command. I can not seem to get this to work.
View 2 Replies
Sep 3, 2010
I have defined a field validator that works fine on normal behavior on a page:
<asp:RequiredFieldValidator runat="server" ErrorMessage="errroooorr" ControlToValidate="TextBoxHouseNumber" Display="Dynamic"></asp:RequiredFieldValidator>
Now if I dont insert any text in the TextBoxHouseNumber field, and push submit, the FieldValidator fires as it should. But if I now click a button that automatically fills the TextBoxHouseNumber with text from a Jquery/Ajax function, the field validator still shows. It´s like "Hey, the user hasnt made any changes to the textbox, so I wont bother check it".
View 6 Replies
Jun 4, 2010
I am having a problem with partial postback through update panel, Update panel is not working properly in my asp.net app with IE8. But app works fine if i switch to compatibility mode of IE8.
View 5 Replies