Difference between EnableViewState and ViewStateMode properties
1. Using EnableViewState property we only have 2 options
We can turn off view state altogether,
or
Enable viewstate for the entire page and then turn it off on a control-by-control basis.
2. If you want to turn of ViewState for the entire page and only enable it for specific controls on the page, then we have to use ViewStateMode property in conjunction with EnableViewState.
3. EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property.
4. ViewStateMode property is introduced in ASP.NET 4, where as EnableViewState exists from a long time.
5. If EnableViewState is to True, only then the ViewStateMode settings are applied, where as, if EnableViewState is set to False then the control will not save its view state, regardless of the ViewStateMode setting. In short if EnableViewState is set to False, ViewStateMode setting is not respected.
6. To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.
Subscribe to:
Post Comments (Atom)
what is majic table?
ReplyDeleteWhen you are using trigger, for insert and deleted, the values are stored in Inserted and deleted table.
Deleteinserted and deleted table are the magic table.
for example:
CREATE TABLE Employee_Test
(
Emp_ID INT Identity,
Emp_name Varchar(100),
Emp_Sal Decimal (10,2)
)
INSERT INTO Employee_Test VALUES ('Anees',1000);
INSERT INTO Employee_Test VALUES ('Rick',1200);
INSERT INTO Employee_Test VALUES ('John',1100);
INSERT INTO Employee_Test VALUES ('Stephen',1300);
INSERT INTO Employee_Test VALUES ('Maria',1400);
CREATE TABLE Employee_Test_Audit
(
Emp_ID int,
Emp_name varchar(100),
Emp_Sal decimal (10,2),
Audit_Action varchar(100),
Audit_Timestamp datetime
)
CREATE TRIGGER trgAfterInsert ON [dbo].[Employee_Test]
FOR INSERT
AS
declare @empid int;
declare @empname varchar(100);
declare @empsal decimal(10,2);
declare @audit_action varchar(100);
select @empid=i.Emp_ID from inserted i;
select @empname=i.Emp_Name from inserted i;
select @empsal=i.Emp_Sal from inserted i;
set @audit_action='Inserted Record -- After Insert Trigger.';
insert into Employee_Test_Audit
(Emp_ID,Emp_Name,Emp_Sal,Audit_Action,Audit_Timestamp)
values(@empid,@empname,@empsal,@audit_action,getdate());
PRINT 'AFTER INSERT trigger fired.'
GO
here inserted is the magic table
Like the answer.............
DeleteYou can use the ViewStateMode property to enable view state for an individual control even if view state is disabled for the page. For more information about view state and control state, see the EnableViewState property. -MSDN
ReplyDeletecan be not use view state mode in .net 3.5 framework ???
Delete@guest ViewStateMode property can be used to enable view state for an individual control, even when ViewStateMode property for the page is disables. but it only works if the EnableViewState property for the page is set to true.
DeleteIn interview, viewstate questions are generally combined with cache, check out the conversation below :
ReplyDeleteQuestion : Is data grid is good candidate for viewstate?
Your Ans : No
Question : Why?
Your Ans : It increases the response time of postbag.
Question : What is another way datagrid data can be stored?
Expected Ans : Cache
In Interview :
ReplyDeleteon webform gridview is there with edit ,checkbox,paging ....now data is bind on gridview
if i disable viewstate for entire page or gridview then - what happen with gridview when i click on any child control in grid view?