Click here to Skip to main content
15,909,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi frnds this is the code
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace student_reg_form
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string g = string.Empty;
            if (RadioButton1.Checked)
                g = RadioButton1.Text;
            else
                g = RadioButton2.Text;
            string c = string.Empty;
            if (RadioButton3.Checked) ;
            c = RadioButton3.Text;
            else if (RadioButton4.Checked;
            c= RadioButton4.Text;
            else
            c= RadioButton5.Text;
            string x =string.Empty;
            if (CheckBox1.Checked)
            x+= CheckBox1.Text+"<br/>";
            if (CheckBox2.Checked)
                x+= CheckBox2.Text+"<br/>";
            if (CheckBox3.Checked)
                x+= CheckBox3.Text+"<br/>";
             if (CheckBox4.Checked)
                x+= CheckBox4.Text+"<br/>";
            Label1.Text= "Name:"+ TextBox1.Text+"<br/>Group":+C+"<br/>selected courses<br/>" +x;
        }

    }
}
Posted
Comments
JoCodes 28-Jan-14 23:47pm    
Whats the error you are getting . Post the error description too
harshavardhan12345678 28-Jan-14 23:49pm    
in this im getting
string c = string.Empty;
if (RadioButton3.Checked) ;
c = RadioButton3.Text;
else if (RadioButton4.Checked;
c= RadioButton4.Text;
else
c= RadioButton5.Text;
string x =string.Empty;
if (CheckBox1.Checked)
x+= CheckBox1.Text+"<br/>";
if (CheckBox2.Checked)
x+= CheckBox2.Text+"<br/>";
if (CheckBox3.Checked)
x+= CheckBox3.Text+"<br/>";
if (CheckBox4.Checked)
x+= CheckBox4.Text+"<br/>";
Label1.Text= "Name:"+ TextBox1.Text+"<br/>Group":+C+"<br/>selected courses<br/>" +x;
JoCodes 28-Jan-14 23:52pm    
How you knew that it has errors? You should get some error messages shown by the compiler. without that how we would know whats the error is?
harshavardhan12345678 28-Jan-14 23:54pm    
last line sir
harshavardhan12345678 29-Jan-14 0:08am    
Message 1 Validation (XHTML 1.0 Transitional): Attribute 'align' is considered outdated. A newer construct is recommended. c:\visual studio 2010\Projects\student reg form\student reg form\Default.aspx 27 16 student reg form
Error 2 Only assignment, call, increment, decrement, and new object expressions can be used as a statement c:\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 26 34 student reg form
Error 3 Only assignment, call, increment, decrement, and new object expressions can be used as a statement c:\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 28 33 student reg form
Error 4 The name 'C' does not exist in the current context c:\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 40 59 student reg form
Error 6 Invalid expression term 'else' c:\\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 27 13 student reg form
Error 7 ; expected c:\\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 27 18 student reg form
Error 8 ) expected c:\\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 27 42 student reg form
Error 9 Invalid expression term 'else' c:\visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 29 13 student reg form
Error 10 ; expected c:visual studio 2010\Projects\student reg form\student reg form\Default.aspx.cs 29 17 student reg form

Modify the last line like

Label1.Text= "Name:"+ TextBox1.Text+"<br />Group:"+C+"<br />selected courses<br />" +x;


Change :

Moved the colon inside the quotes
Assuming C and X are declared String variables.
 
Share this answer
 
Quote:
Message 1 Validation (XHTML 1.0 Transitional): Attribute 'align' is considered outdated. A newer construct is recommended
Replace the align="center" with style="text-align:center"

This will resolve the validation error you are getting and satisfy the XHTML rules also.
 
Share this answer
 
Lot of syntax errors,
corrected,
Try this.

C#
string g = string.Empty;
           if (RadioButton1.Checked)
               g = RadioButton1.Text;
           else
               g = RadioButton2.Text;
           string c = string.Empty;
           if (RadioButton3.Checked)
           c = RadioButton3.Text;
           else if (RadioButton4.Checked)
           c= RadioButton4.Text;
           else
           c= RadioButton5.Text;
           string x =string.Empty;
           if (CheckBox1.Checked)
           x+= CheckBox1.Text+"<br/>";
           if (CheckBox2.Checked)
               x+= CheckBox2.Text+"<br/>";
           if (CheckBox3.Checked)
               x+= CheckBox3.Text+"<br/>";
            if (CheckBox4.Checked)
               x+= CheckBox4.Text+"<br/>";
           Label1.Text= "Name:"+ TextBox1.Text+"<br/>Group:"+C+"<br/>selected courses<br/>" +x;
 
Share this answer
 
Okay,

Modify this line of code in your .aspx page:

<table align="center" class="style1">


to

<table class="style1"> // remove the alert attribute as it's obsolete.


use CSS to handle the alignment. That's all you need to do.

Run and check if your application is working fine now.

Hope it helps!

Happy Coding :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900