R
Ron
Hello all,
I don't understand why my pageis not posting back to the server when I
change the selection on a radio list.
I have a page that both accepts new personal info. or allows editing
to existing info depending on the parameter passed from previous
pages. The radio is supposed to disable the password (and confirm
password) text boxes as well as their validation controls. However,
when you click 'No' (This should perform the above tasks) nothing
happens. However, when you click submit to enter the edited
information: it posts back, performs the OnSelectedIndexChanged
procedure of the radio list as well as the OnClick of the button.
Grrr.
Below is (hopefully) as much code needed to disect the issue while
trying to keep as brief as possible. I thank you in advance.
--Start of code--
<html>
<script runat="server">
sub page_load (source as object, e as eventargs)
FormType.text = "Enter New Employee"
if len(session("empnum")) = 6 then
FormTypeVar = "Edit"
FormType.text = "Edit Personal Information"
else
emppass.enabled = true
empconfirm.enabled = true
end if
If not ispostback and formtypevar = "Edit" then
passchange.enabled = "true"
fill_page() --fills fields with info from DB
end if
end sub
sub Submit_Click (sender as object, e as eventargs)
If page.isvalid then
If FormTypeVar = "New" Then
--perform tasks for adding new employee
Else
--perform tasks for editing info
end if
end if
sub togglepass(sender as object, e as eventargs)
dim temp as boolean = passchange.selecteditem.value
if temp then
passoff = false
emppass.enabled = true
empconfirm.enabled = true
pwvalid.enabled = true
else
passoff = true
emppass.enabled = false
empconfirm.enabled = false
pwvalid.enabled = false
end if
end sub
<body>
<form runat="server">
Password:
<asp:TextBox id="emppass" runat="server" textmode="password"
Columns="25" />
<asp:CustomValidator id="pwvalid" OnServerValidate="password_validate"
errormessage="Your passwords did not match, please try again."
runat="server">*</asp:customValidator>
<asp:TextBox id="empconfirm" runat="server" textmode="password"
Columns="25" />
Change your password?
<asp:RadioButtonList ID="passchange" Enabled="false" RepeatColumns="2"
OnSelectedIndexChanged="togglepass" AutoPostBack="true" runat="server"
<asp:ListItem Value=true Text="Yes" Selected="true"/>
<asp:ListItem Value=false Text="No"/>
</asp:RadioButtonList>
<asp:Button id="submit" onclick="submit_click" text="Submit"
runat="server"/>
</form>
--etc.
I don't understand why my pageis not posting back to the server when I
change the selection on a radio list.
I have a page that both accepts new personal info. or allows editing
to existing info depending on the parameter passed from previous
pages. The radio is supposed to disable the password (and confirm
password) text boxes as well as their validation controls. However,
when you click 'No' (This should perform the above tasks) nothing
happens. However, when you click submit to enter the edited
information: it posts back, performs the OnSelectedIndexChanged
procedure of the radio list as well as the OnClick of the button.
Grrr.
Below is (hopefully) as much code needed to disect the issue while
trying to keep as brief as possible. I thank you in advance.
--Start of code--
<html>
<script runat="server">
sub page_load (source as object, e as eventargs)
FormType.text = "Enter New Employee"
if len(session("empnum")) = 6 then
FormTypeVar = "Edit"
FormType.text = "Edit Personal Information"
else
emppass.enabled = true
empconfirm.enabled = true
end if
If not ispostback and formtypevar = "Edit" then
passchange.enabled = "true"
fill_page() --fills fields with info from DB
end if
end sub
sub Submit_Click (sender as object, e as eventargs)
If page.isvalid then
If FormTypeVar = "New" Then
--perform tasks for adding new employee
Else
--perform tasks for editing info
end if
end if
sub togglepass(sender as object, e as eventargs)
dim temp as boolean = passchange.selecteditem.value
if temp then
passoff = false
emppass.enabled = true
empconfirm.enabled = true
pwvalid.enabled = true
else
passoff = true
emppass.enabled = false
empconfirm.enabled = false
pwvalid.enabled = false
end if
end sub
<body>
<form runat="server">
Password:
<asp:TextBox id="emppass" runat="server" textmode="password"
Columns="25" />
<asp:CustomValidator id="pwvalid" OnServerValidate="password_validate"
errormessage="Your passwords did not match, please try again."
runat="server">*</asp:customValidator>
<asp:TextBox id="empconfirm" runat="server" textmode="password"
Columns="25" />
Change your password?
<asp:RadioButtonList ID="passchange" Enabled="false" RepeatColumns="2"
OnSelectedIndexChanged="togglepass" AutoPostBack="true" runat="server"
<asp:ListItem Value=true Text="Yes" Selected="true"/>
<asp:ListItem Value=false Text="No"/>
</asp:RadioButtonList>
<asp:Button id="submit" onclick="submit_click" text="Submit"
runat="server"/>
</form>
--etc.