468,765 Members | 860 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Problems with Postback

I have a page that has been displaying some weird behavior.

I have 2 radio buttons that work fine until I press the link button with an
item selected in my link box (if an item is not selected, there is no
problem).

This makes no sense. I am not doing anything with the item in the listbox.
It just has to be selected.

What happens is that once this starts happening, the radio buttons WILL NOT
stay selected. So the page quits working.

If I don't select either of the items in the listbox, I can press the
Linkbutton all day and the radio buttons will work. But once I select it,
the radio buttons will never work again.

What is wrong here?

Is this a bug in Asp? There is no Database access here, so that is not the
problem.

I can't figure this out nor can anyone I work with.

I have stripped out everything that is not related to the problem.

Anyone have an idea as to what is causing this problem???

************************************************** ****
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
End Sub

Sub GetScreenNames_Checked(s as Object, e as EventArgs)
End Sub

Sub LinkJob_Click(s as Object,e as EventArgs)
End Sub

</script>
</head>

<body id="myBody" runat="server">
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<br>
<table border="0" width="650" style="border-collapse:collapse" >
<tr>
<td width="701">
<asp:RadioButton ID="ScreenTests" Text="Screening"
TextAlign="right" AutoPostBack="true"
OnCheckedChanged="GetScreenNames_Checked" GroupName="Positions"
runat="server" Checked="true" />
<asp:RadioButton ID="SkillsTests" Text="Skills" TextAlign="right"
AutoPostBack="true" OnCheckedChanged="GetScreenNames_Checked"
GroupName="Positions" runat="server" /> </td>
</tr>
<tr>
<td ><asp:ListBox ID="Positions" SelectionMode="multiple" Rows="8"
Width="600" runat="server">
<asp:ListItem Value="1">This is Line 1</asp:ListItem>
<asp:ListItem Value="2">This is Line 2</asp:ListItem>
</asp:ListBox>
</td>
</tr>
<tr>
<td >
<asp:LinkButton ID="LinkJob" Text="Link Job"
OnClick="LinkJob_Click" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</html>
************************************************** *****

Thanks,

Tom
Jan 16 '06 #1
2 1032
I tried to do the exact same thing using vs.net (2003) and it works fine.

What is the difference? The code is straight forward and is doing nothing
in the events - just returning:

Here are the 2 vs.net files:

************************************************** *********************
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication5.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
<asp:RadioButton id="ScreenTests" Text="Screening" TextAlign="right"
AutoPostBack="true" OnCheckedChanged="ScreenTests_CheckedChanged"
GroupName="Positions" runat="server"></asp:RadioButton>
<asp:RadioButton id="Skillstests" Text="Skills" TextAlign="right"
AutoPostBack="true" OnCheckedChanged="Skillstests_CheckedChanged"
GroupName="Positions" runat="server"></asp:RadioButton></P>
<P>
<asp:ListBox id="ListBox1" runat="server">
<asp:ListItem Value="1">This is Line 1</asp:ListItem>
<asp:ListItem Value="2">This is Line 2</asp:ListItem>
</asp:ListBox></P>
<P>
<asp:LinkButton id="LinkButton1" Text="Link Job"
OnClick="Skillstests_CheckedChanged" runat="server" /></P>
</form>
</body>
</HTML>
************************************************** *********************

************************************************** **********************
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents ScreenTests As
System.Web.UI.WebControls.RadioButton
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox
Protected WithEvents LinkButton1 As System.Web.UI.WebControls.LinkButton
Protected WithEvents Skillstests As
System.Web.UI.WebControls.RadioButton

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click

End Sub

Public Sub ScreenTests_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ScreenTests.CheckedChanged

End Sub

Public Sub Skillstests_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Skillstests.CheckedChanged

End Sub
End Class
************************************************** **********************

Thanks,

Tom

"tshad" <tf*@dslextreme.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a page that has been displaying some weird behavior.

I have 2 radio buttons that work fine until I press the link button with an item selected in my link box (if an item is not selected, there is no
problem).

This makes no sense. I am not doing anything with the item in the listbox. It just has to be selected.

What happens is that once this starts happening, the radio buttons WILL NOT stay selected. So the page quits working.

If I don't select either of the items in the listbox, I can press the
Linkbutton all day and the radio buttons will work. But once I select it,
the radio buttons will never work again.

What is wrong here?

Is this a bug in Asp? There is no Database access here, so that is not the problem.

I can't figure this out nor can anyone I work with.

I have stripped out everything that is not related to the problem.

Anyone have an idea as to what is causing this problem???

************************************************** ****
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
End Sub

Sub GetScreenNames_Checked(s as Object, e as EventArgs)
End Sub

Sub LinkJob_Click(s as Object,e as EventArgs)
End Sub

</script>
</head>

<body id="myBody" runat="server">
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<br>
<table border="0" width="650" style="border-collapse:collapse" >
<tr>
<td width="701">
<asp:RadioButton ID="ScreenTests" Text="Screening"
TextAlign="right" AutoPostBack="true"
OnCheckedChanged="GetScreenNames_Checked" GroupName="Positions"
runat="server" Checked="true" />
<asp:RadioButton ID="SkillsTests" Text="Skills" TextAlign="right" AutoPostBack="true" OnCheckedChanged="GetScreenNames_Checked"
GroupName="Positions" runat="server" /> </td>
</tr>
<tr>
<td ><asp:ListBox ID="Positions" SelectionMode="multiple" Rows="8"
Width="600" runat="server">
<asp:ListItem Value="1">This is Line 1</asp:ListItem>
<asp:ListItem Value="2">This is Line 2</asp:ListItem>
</asp:ListBox>
</td>
</tr>
<tr>
<td >
<asp:LinkButton ID="LinkJob" Text="Link Job"
OnClick="LinkJob_Click" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</html>
************************************************** *****

Thanks,

Tom

Jan 16 '06 #2
I rewrote the program in VS 2003 and found that the radio buttons would
work, but now the listbox doesn't work correctly.

I select an item in the listbox and press the link button, which just tells
me which line is selected. It gives me back a -1 (no line selected) and
clears the line. The next time I select a line it works fine. I can select
all the lines I want and each time I hit the link button it sees the line
file.

Only the first time, does it have a problem.

Is there some sort of initialization problem that I am having?

Thanks,

Tom

"tshad" <tf*@dslextreme.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I tried to do the exact same thing using vs.net (2003) and it works fine.

What is the difference? The code is straight forward and is doing nothing
in the events - just returning:

Here are the 2 vs.net files:

************************************************** *********************
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication5.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
<asp:RadioButton id="ScreenTests" Text="Screening"
TextAlign="right"
AutoPostBack="true" OnCheckedChanged="ScreenTests_CheckedChanged"
GroupName="Positions" runat="server"></asp:RadioButton>
<asp:RadioButton id="Skillstests" Text="Skills" TextAlign="right"
AutoPostBack="true" OnCheckedChanged="Skillstests_CheckedChanged"
GroupName="Positions" runat="server"></asp:RadioButton></P>
<P>
<asp:ListBox id="ListBox1" runat="server">
<asp:ListItem Value="1">This is Line 1</asp:ListItem>
<asp:ListItem Value="2">This is Line 2</asp:ListItem>
</asp:ListBox></P>
<P>
<asp:LinkButton id="LinkButton1" Text="Link Job"
OnClick="Skillstests_CheckedChanged" runat="server" /></P>
</form>
</body>
</HTML>
************************************************** *********************

************************************************** **********************
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents ScreenTests As
System.Web.UI.WebControls.RadioButton
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox
Protected WithEvents LinkButton1 As
System.Web.UI.WebControls.LinkButton
Protected WithEvents Skillstests As
System.Web.UI.WebControls.RadioButton

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click

End Sub

Public Sub ScreenTests_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ScreenTests.CheckedChanged

End Sub

Public Sub Skillstests_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Skillstests.CheckedChanged

End Sub
End Class
************************************************** **********************

Thanks,

Tom

"tshad" <tf*@dslextreme.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have a page that has been displaying some weird behavior.

I have 2 radio buttons that work fine until I press the link button with

an
item selected in my link box (if an item is not selected, there is no
problem).

This makes no sense. I am not doing anything with the item in the

listbox.
It just has to be selected.

What happens is that once this starts happening, the radio buttons WILL

NOT
stay selected. So the page quits working.

If I don't select either of the items in the listbox, I can press the
Linkbutton all day and the radio buttons will work. But once I select
it,
the radio buttons will never work again.

What is wrong here?

Is this a bug in Asp? There is no Database access here, so that is not

the
problem.

I can't figure this out nor can anyone I work with.

I have stripped out everything that is not related to the problem.

Anyone have an idea as to what is causing this problem???

************************************************** ****
<%@ Page Language="VB" trace="false" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>:: Staffing Workshop ::</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
End Sub

Sub GetScreenNames_Checked(s as Object, e as EventArgs)
End Sub

Sub LinkJob_Click(s as Object,e as EventArgs)
End Sub

</script>
</head>

<body id="myBody" runat="server">
<form id="Form1" runat="server">
<input type="hidden" name="__SCROLLPOS" value="" />
<br>
<table border="0" width="650" style="border-collapse:collapse" >
<tr>
<td width="701">
<asp:RadioButton ID="ScreenTests" Text="Screening"
TextAlign="right" AutoPostBack="true"
OnCheckedChanged="GetScreenNames_Checked" GroupName="Positions"
runat="server" Checked="true" />
<asp:RadioButton ID="SkillsTests" Text="Skills"

TextAlign="right"
AutoPostBack="true" OnCheckedChanged="GetScreenNames_Checked"
GroupName="Positions" runat="server" /> </td>
</tr>
<tr>
<td ><asp:ListBox ID="Positions" SelectionMode="multiple"
Rows="8"
Width="600" runat="server">
<asp:ListItem Value="1">This is Line 1</asp:ListItem>
<asp:ListItem Value="2">This is Line 2</asp:ListItem>
</asp:ListBox>
</td>
</tr>
<tr>
<td >
<asp:LinkButton ID="LinkJob" Text="Link Job"
OnClick="LinkJob_Click" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</html>
************************************************** *****

Thanks,

Tom


Jan 16 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by BluDog | last post: by
1 post views Thread by Steve Loper | last post: by
5 posts views Thread by WesIdell | last post: by
3 posts views Thread by moshi | last post: by
1 post views Thread by Jason | last post: by
3 posts views Thread by =?Utf-8?B?TWlndWVsIElzaWRvcm8=?= | last post: by
reply views Thread by rn5a | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.