943,722 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 892
  • ASP RSS
Jul 8th, 2009
1

Radio button message

Expand Post »
I have a radio button list and I need to display a lable message when ever user select "A"
i wrote some code in c# but its not working can sombody help me.
ASP Syntax (Toggle Plain Text)
  1. <td align="left" >
  2. <asp:RadioButtonList ID="RBl1" runat="server" AutoPostBack="True"
  3. CellPadding="2" CellSpacing="5"
  4. onselectedindexchanged="RBl1_SelectedIndexChanged">
  5. <asp:ListItem Value="G" Selected="True" >Regular Grants</asp:ListItem>
  6. <asp:ListItem Value ="A">ARRA Grants</asp:ListItem>
  7. <asp:ListItem Value ="C">Contract</asp:ListItem>
  8. </asp:RadioButtonList>
  9.  
  10. </td>

ASP Syntax (Toggle Plain Text)
  1. protected void RBl1_SelectedIndexChanged(object sender, EventArgs e)
  2. {
  3. if (RBl1.SelectedValue = "A")
  4. {
  5. mesg.text = "ARRA FUNDS NOT AVAILABLE" ;
  6. }
  7. else
  8. lblmsg.Text="";
  9.  
  10. MakeSQL();
  11.  
  12. }
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pt0909 is offline Offline
21 posts
since Jul 2009
Jul 12th, 2009
0

Re: Radio button message

Hello, pt0909.
To compare values you should use "==".
c# Syntax (Toggle Plain Text)
  1. if (RBl1.SelectedValue == "A")
.

Also the property of the label, which you trying to access here:
c# Syntax (Toggle Plain Text)
  1. mesg.text
should start with the capital letter:
c# Syntax (Toggle Plain Text)
  1. mesg.Text

C# is case-sensitive.
Reputation Points: 293
Solved Threads: 82
Posting Whiz
Antenka is offline Offline
361 posts
since Nov 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Eval() Method - Help please
Next Thread in ASP Forum Timeline: display records in asp panel page wise





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC