viewstate

Dynamically adding controls to ASP.NET - viewstate is not retained after 20 minutes

限于喜欢 提交于 2019-12-20 04:25:21
问题 We have a ASP.net form [.NET 3.5 on IIS 6] that loads controls dynamically. We are able to retain the values in the viewstate as long as the postback happens within 20 minutes . The database also gets updated properly. Everything works as expected. However, If it takes more than 20 minutes for a user to fill out the form, the controls no longer retain their values during postbacks. The session values are intact, the user authentication is also intact. We tried several things 1) Added machine

Gridview ControlState very large even when viewstate disabled and not using DataKeyNames

∥☆過路亽.° 提交于 2019-12-20 02:37:38
问题 I have an asp:Gridview bound to an asp:ObjectDataSource. I have disabled the ViewState on the GridView, and have not set the DataKeyNames property. I have about 10 BoundFields and a few TemplateFields. These TemplateFields are not bound to server controls but to an anchor tag or to an img tag. However, at runtime, when I switch on page tracing I see that the ControlState of the Gridview varies between 7 and 12K for displaying just 14 rows of data. (View source on the rendered page also gives

Can malicious users modify viewstate?

北城以北 提交于 2019-12-20 01:08:18
问题 If ViewStatemac is enabled in an ASP.NET application can a user modify what is in ViewState and successfully pass it back to the server? I have an applicaiton (that someone else wrote) that is using what is in ViewState to create an non-parameterized ORDER BY clause in a SQL query. Should I be worried about SQL Injection? 回答1: If ViewStateMAC is enabled the attacker would need to be able to crack the "machine key" in order to alter the ViewState, so it should be reasonably secure if this

Dynamically created DropDownList loses ListItems on Postback

痞子三分冷 提交于 2019-12-19 17:33:21
问题 I have a page that contains some dynamically created controls (TextBox and DropDownList). When a postback occurs, the TextBoxes keep their values, but the DropDownLists lose their ListItems. This is quite confusing, since the page level DropDownList also keeps its ListItems. Can anyone see what's wrong with the code below? Any help in solving this issue would be greatly appreciated. <%@ Page Language="VB"%> <script runat="server"> Protected Sub Page_Init(ByVal sender As Object, ByVal e As

Insert TextBoxes into a Repeater dynamically and retrieve their value

六月ゝ 毕业季﹏ 提交于 2019-12-19 11:46:35
问题 I have a Repeater bound from SQL, containing a mixture of editable and read-only elements. When you click the "Edit" button on a row, the editable portions should convert to textboxes, and when you click "Update", it should save your changes. Here's a (very) simplified version of the Edit and Update buttons' OnClick code: switch(commandName) { case "Edit": Label1.Visible = false; //hide read-only version PlaceHolder1.Visible = true; //show editing version //Dict1 is Dictionary<string, string>

Validation of viewstate MAC failed when on page for 20+ minutes

孤街醉人 提交于 2019-12-18 13:24:28
问题 If you open a web page on one of the websites hosted on our server, leave it for 20 minutes and then submit a form, a Validation of viewstate MAC failed. error occurs. What possible reasons could there be for this? 回答1: There's a few reasons this can happen: Auto-Generated Machine Keys: If your application pools have the default idle timeout of 20 minutes AND you're using auto-generated validation and decryption keys then each time the pool starts it will generate a new set of keys. This

Keeping Data in GridView after PostBack

ε祈祈猫儿з 提交于 2019-12-18 08:58:15
问题 I have a GridView which is associated with an SqlDataSource . When I click a Button , I change the SelectCommand and then I use DataBind to update the GridView . After PostBack, I want the latest Data to Remain, I don't want the GridView to be loaded by the original SelectCommand . I know this is done by something called ViewState , but I didn't manage to implement it in the right way. I tried both EnableViewState="true" and EnableViewState="false" on the Grid itself, with no luck. Code <asp

.net ViewState in page lifecycle

自闭症网瘾萝莉.ら 提交于 2019-12-18 08:46:08
问题 I have a page containing a control called PhoneInfo.ascx. PhoneInfo is dynamically created using LoadControl() and then the initControl() function is called passing in an initialization object to set some initial textbox values within PhoneInfo. The user then changes these values and hits a submit button on the page which is wired up to the "submit_click" event. This event invokes the GetPhone() function within PhoneInfo. The returned value has all of the new user entered values except that

does gridview save data in viewstate?

大兔子大兔子 提交于 2019-12-18 06:59:23
问题 hi i bind a DataTable to a gridview. i want to use the DataTable in some postback event, and ii want to use viewstate. does gridview save data in viewstate? if no what is the best way to do this. (full story : i have a custom gridview derived from standard asp.net gridview, and i put a button in header to export data to excel, i want to use data saved in viewstate to export to excel) thanks 回答1: The short answer is yes, information shown in the GridView, much like the current state of any

does gridview save data in viewstate?

孤街醉人 提交于 2019-12-18 06:59:14
问题 hi i bind a DataTable to a gridview. i want to use the DataTable in some postback event, and ii want to use viewstate. does gridview save data in viewstate? if no what is the best way to do this. (full story : i have a custom gridview derived from standard asp.net gridview, and i put a button in header to export data to excel, i want to use data saved in viewstate to export to excel) thanks 回答1: The short answer is yes, information shown in the GridView, much like the current state of any