473,378 Members | 1,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Checkbox viewstate

Hi,

Maybe I'm crazy but...

I'm going to try to explain this ¿"bug"?

I've 2 aspx pages.

In page 1:

1 checkbox with default properties

1 textbox with autopostback=true

1 button

Page 2 is a blank page.

First I've checked the checkbox control and then I've click the
button.

Page 2 is open and then I close this second page.

Then when Page 1 appears again checkbox checked property value is
false!!!

How it's possible??

If I set autopostback property of textbox control to false, everything
works fine!!!

Thanks in advance.

Page 1 aspx
code-----------------------------------------------------------------------

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_test.aspx.vb" Inherits="_test" Debug="false"
Explicit="true" Strict="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin título</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox2" runat="server" Text="Checkbox" /
><br />
<asp:TextBox ID="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />

</div>
</form>
</body>
</html>
Page 1 codebehind--------------------------------------------------

Partial Class _test
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strscript As String
strscript =
"<script>window.showModalDialog('_nothing.aspx','' ,'dialogWidth:
460px;dialogHeight:350px'); __doPostBack('','');</script>"
ClientScript.RegisterClientScriptBlock(GetType(_te st),
"s_window", strscript, False)
End Sub
End Class
Page 2 aspx
code------------------------------------------------------------

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_nothing.aspx.vb" Inherits="_nothing" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin título</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

May 15 '07 #1
2 1778
Try using ClientScript.RegisterStartupScript () instead of
ClientScript.RegisterClientScriptBlock().

"Davix" wrote:
Hi,

Maybe I'm crazy but...

I'm going to try to explain this ¿"bug"?

I've 2 aspx pages.

In page 1:

1 checkbox with default properties

1 textbox with autopostback=true

1 button

Page 2 is a blank page.

First I've checked the checkbox control and then I've click the
button.

Page 2 is open and then I close this second page.

Then when Page 1 appears again checkbox checked property value is
false!!!

How it's possible??

If I set autopostback property of textbox control to false, everything
works fine!!!

Thanks in advance.

Page 1 aspx
code-----------------------------------------------------------------------

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_test.aspx.vb" Inherits="_test" Debug="false"
Explicit="true" Strict="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin tÃ*tulo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox2" runat="server" Text="Checkbox" /
<br />
<asp:TextBox ID="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />

</div>
</form>
</body>
</html>
Page 1 codebehind--------------------------------------------------

Partial Class _test
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strscript As String
strscript =
"<script>window.showModalDialog('_nothing.aspx','' ,'dialogWidth:
460px;dialogHeight:350px'); __doPostBack('','');</script>"
ClientScript.RegisterClientScriptBlock(GetType(_te st),
"s_window", strscript, False)
End Sub
End Class
Page 2 aspx
code------------------------------------------------------------

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_nothing.aspx.vb" Inherits="_nothing" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin tÃ*tulo</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>

May 16 '07 #2
On 16 mayo, 09:24, Siva M <shiva...@online.excite.comwrote:
Try using ClientScript.RegisterStartupScript () instead of
ClientScript.RegisterClientScriptBlock().

"Davix" wrote:
Hi,
Maybe I'm crazy but...
I'm going to try to explain this ¿"bug"?
I've 2 aspx pages.
In page 1:
1 checkbox with default properties
1 textbox with autopostback=true
1 button
Page 2 is a blank page.
First I've checked the checkbox control and then I've click the
button.
Page 2 is open and then I close this second page.
Then when Page 1 appears again checkbox checked property value is
false!!!
How it's possible??
If I set autopostback property of textbox control to false, everything
works fine!!!
Thanks in advance.
Page 1 aspx
code-----------------------------------------------------------------------
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_test.aspx.vb" Inherits="_test" Debug="false"
Explicit="true" Strict="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin título</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox2" runat="server" Text="Checkbox" /
><br />
<asp:TextBox ID="TextBox1" runat="server"
AutoPostBack="True"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
</div>
</form>
</body>
</html>
Page 1 codebehind--------------------------------------------------
Partial Class _test
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strscript As String
strscript =
"<script>window.showModalDialog('_nothing.aspx','' ,'dialogWidth:
460px;dialogHeight:350px'); __doPostBack('','');</script>"
ClientScript.RegisterClientScriptBlock(GetType(_te st),
"s_window", strscript, False)
End Sub
End Class
Page 2 aspx
code------------------------------------------------------------
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="_nothing.aspx.vb" Inherits="_nothing" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Página sin título</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>- Ocultar texto de la cita -

- Mostrar texto de la cita -
Thank you very much, it works.
You are my salvation.
Thanks a lot

May 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steven | last post by:
Hi, I'm creating a custom checkbox list control which will take 2 arraylists as input. (One will contain Names and other will contain 0s and 1s. 0 - uncheck 1- check). I'm able to create the...
5
by: Greg Hurlman | last post by:
I've got a very simple ASCX page, where once someone finishes a section and clicks the "Next >" button, the section they just finished is disabled, and the next section appears below it, and so on....
4
by: RodBillett | last post by:
I have a situation where I have 3 checkboxes - and at least 1 needs to be selected at all times... I have implemented the code that allows this behavior to happen, BUT Viewstate gets all messed...
3
by: eSapient | last post by:
I created a web page which contains a form which contains a table. The number of rows for the table are determined dynamically. The first cell of each row contains a HyperLink control and the last...
6
by: Alessandro Rossi | last post by:
Hi, I have to create a CheckBox, and i would like will be checked if there is a value in a property added, and not checked if there is another value. I added 2 property (string) to the checkbox;...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
1
by: Ramakrishnan Nagarajan | last post by:
Hi, I have two checkboxes in each row of a grid. One for Modify and another one for View. If I click Modify the View should get automatically checked and should be disabled. Earlier I did this in...
1
by: mercercreek | last post by:
This one should be easy. Hope someone has a clue. Simple Scenario: Gridview with mulitple rows, each row with a checkbox. The user checks boxes of her choice. Clicks a button on the form (not in...
10
by: LionsDome | last post by:
Hello, I have a vb.net page which a bunch of checkboxes. A user can select a checkbox(s) and hit the submit button to store those values in a SQL Server table. This works fine with no problem...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.