am using 2 radio buttons in my form. rAdmin and rDesigner.
<
input type=radio id=rDesigner runat=server name=userType onserverchange="rDesigner_ServerChange"> <input type=radio id=rAdmin runat=server name=userType onserverchange="rAdmin_ServerChange">when the user selects either radiobuttons, data is displayed based on which radio button is selected.
where should i write the code for displaying these data
there is no onserverclick event available. i tried to write the code in onserverchange event.
protected
void rDelUsers_ServerChange(object sender, EventArgs e){
// my code to display data
}
but when the user clicks(selects) the radiobutton, this event is not called.
how can i correct it
pls help.....
Sajitha

radio button's "selected" event
smitchzilla
grrrrrrrrrrrrr. . .
it doesnt like checked="CHECKED" even though thats what the IDE puts in there. . .
It parses and renders checked="true" but it displays a XHTML lack of compliance error.
go figure
Richard Petkiewicz
quick question -
Do you really want to post back to get the data to display how much data is it
Matt Hope
did you accidentally delete it Maybe we found a bug and mr gates is silencing us
as far as your data hidding on button click. . .
for prototyping purposes paste this in a textpage . . . save as c:\foo.htm and browse to file://c:\foo.htm . . would something like this be adequate
=========== begin html ==========
<html>
<script>
function viewData()
{
if (document.getElementById("btn1").checked)
document.getElementById("data1").style.visibility = "visible";
else
document.getElementById("data1").style.visibility = "hidden";
if (document.getElementById("btn2").checked)
document.getElementById("data2").style.visibility = "visible";
else
document.getElementById("data2").style.visibility = "hidden";
}
</script>
<body>
<input id="btn1" name="btn1" border="1" type="radio" checked="checked" onclick="viewData();"/> Button1 <br />
<input id="btn2" name="btn1" border="0" type="radio" onclick="viewData();"/> Button2 <br />
<div>
<span id="data1" style="visibility:visible; position:absolute; left:0px">Data for button 1</span>
<span id="data2" style="visibility:hidden; position:absolute; left:0px">Data for button 2</span>
</div>
</body>
</html>
=========== end html ==========
Jeff Lewus
am doing the same . ie changing the visibility property of data based on the radiobutton clicked. but i wrote server side code for that.
protected
void rbDesigner_CheckedChanged(object sender, EventArgs e){
PlaceHolder1.Visible =
true;PlaceHolder2.Visible =
false;PlaceHolder3.Visible =
false;}
protected void rbAdmin_CheckedChanged(object sender, EventArgs e){
PlaceHolder1.Visible =
false;PlaceHolder2.Visible =
true;PlaceHolder3.Visible =
false;}
protected void rbDelUser_CheckedChanged(object sender, EventArgs e){
PlaceHolder1.Visible =
false;PlaceHolder2.Visible =
false;PlaceHolder3.Visible =
true;}
thats why i wanted my <input type=radio> to have runat=server tag and execute these codes.
if its possible through client side code as u wrote, then let me try that. now i am preparing only a prototype. but when i start building the original site, i need to include database commands and other complex functions. so i hv to depend on server side code again. i am displaying datagrids (Gridview control in .net 2005) with different data based on radio button selection.
anyway thanks for your help..
then about my other "thread"........... i was writing a reply to ur post, but suddenly i changed my decision and click on the BACK button of my IE to go back to read ur message again. soon i got an error message , that the page you requested doesnot exist...
sometimes...... Mr.Gates ...... !!!!!!!!!
Mervin Lobo
now i understood the problem is with my webpage .
i tried this in a fresh new page.
<asp:RadioButton ID="RadioButton1" runat="server" />it comes with no border by default. i dont need to set its border attribute to 0 in my code.
but when i write the same <asp:RadioButton ID="RadioButton1" runat="server" /> code in the "page" am working on, it comes with a border and it never goes by setting
RadioButton1.Attributes.Add("border", "0");
so something wrong somewhere in my page.
------------------------------
my other thread posted in windows gerneral section "radio button, border problem" is not accessible to me now. i donno why. its MISSING!!!!!!!!!!!!!
ali Naqvi
installing some software right now, cant run VS.
when you browse that page, what is the rendered html. . . paste that here
rbaxter
i tried using client side coding.
<script language=javascript>
function viewData()
{
if (document.getElementById("rbDesigner").checked)
document.getElementById("PlaceHolder1").style.visibility = "visible";
else
document.getElementById("PlaceHolder2").style.visibility = "hidden";
if (document.getElementById("rbAdmin").checked)
document.getElementById("PlaceHolder1").style.visibility = "visible";
else
document.getElementById("PlaceHolder2").style.visibility = "hidden";
}
</script>
<input type=radio name=usertype onclick="viewData();" runat=server style="border:none" id="rbDesigner"> Designer <br>
<input type=radio name=usertype onclick="viewData();" runat=server style="border:none" id="rbAdmin"> Administrator
<asp:PlaceHolder ID="PlaceHolder1" Visible=false runat="server">
<asp:PlaceHolder ID="PlaceHolder2" runat="server">
still its not working. the runtime error is "OBJECT REQUIRED"
then about using <asp:radiobutton>
its working nice . ie it displays data based on the button selection. the only problem with this was the "border"
now am able to solve it.
actully the problem was with a stylesheet i used for the project. i changed some settings in that style sheet. and now its ok.
as u said, if data is less then its better to use client side code, right
pls help me to correct my client side code.
gregger
oops. . . that was for the asp:radiobutton! Quit switching up on me!!!
KyleB
there is no "autopostback" property for <input type="radio">
so what i will do
Chai.B
cool. . . just keep your users in mind. Are they gonna like a postback just because the changed a radio button
you can run the spans at the server, and write html inside them or you can keep them client side and web controls in them. IT all depends on how much data you want to hide/show.
cheers!
wwitzke
use spans. . . put your web controls in the spans. . .
(I think the client script could be done easier, but this isn't my forte)
==========begin aspx ================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Untitled Page</title>
</head>
<script type="text/javascript">
function viewData()
{
if (document.getElementById("rbDesigner").checked)
document.getElementById("spanDesigner").style.visibility = "visible";
else
document.getElementById("spanDesigner").style.visibility = "hidden";
if (document.getElementById("rbAdmin").checked)
document.getElementById("spanAdmin").style.visibility = "visible";
else
document.getElementById("spanAdmin").style.visibility = "hidden";
}
</script>
<body>
<form id="form1" runat="server">
<input type="radio" name="usertype" onclick="viewData();" runat="server" style="border:none" id="rbDesigner" checked="CHECKED" /> Designer <br />
<input type="radio" name="usertype" onclick="viewData();" runat="server" style="border:none" id="rbAdmin" /> Administrator
<div id="spanDiv">
<span id="spanDesigner" style="visibility:visible;position:absolute;left:0px" >
<asp:TextBox ID="DesignerTextBox" runat="server" />
</span>
<span id="spanAdmin" style="visibility:hidden;position:absolute;left:0px">
<asp:TextBox ID="AdminTextBox" runat="server" />
</span>
</div>
</form>
</body>
</html>
========== end aspx ================
========== cs partial class file ================
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected override void OnLoad(EventArgs e)
{
DesignerTextBox.Text = "This is the Designer Text";
AdminTextBox.Text = "This is the Admin Text";
}
}
========== end partial class file ================
Ryan Jones
that was a friendly growl!
I'm thinking! I'm thinking!
Peter Mo.
michael olson
pls dont get angry at me
am only a beginner. so pls be specific when u post answers.
pls help me