注册 登录
编程论坛 ASP.NET技术论坛

C# ASP.NET新手问题

雪雨星风 发布于 2008-02-24 23:45, 1220 次点击
//谁有简单的方法实现此功能
protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        string name, sex, like, introduce;
        like = "";
        name = this.Text2.Value;
        if (this.Radio1.Checked == true)
        {
            sex = "  男";
        }
        else
        {
            sex = "  女";
        }
        //like = this.Text3.Value;
        if (this.Checkbox1.Checked == true)
        {
            like += "  体育  ";
        }
        if (this.Checkbox2.Checked == true)
        {
            like += "美术  ";
        }
        if (this.Checkbox3.Checked == true)
        {
            like += "计算机  ";
        }
        if (this.Checkbox4.Checked == true)
        {
            like += "游戏  ";
        }
        introduce = this.TextArea1.Value;
        this.DIV1.InnerHtml = "姓名:"+name+"<br>"+"性别:"+sex+"<br>"+"爱好:"+like+"<br>"+"简介:"+introduce+"<br>";
    }
5 回复
#2
仰望星空2008-02-25 11:04
应该没有更好的方式了,不过要是用html控件应该就没这么麻烦了
#3
bygg2008-02-25 11:26
if (this.Checkbox1.Checked == true)
        {
            like += "  体育  ";
        }
        if (this.Checkbox2.Checked == true)
        {
            like += "美术  ";
        }
        if (this.Checkbox3.Checked == true)
        {
            like += "计算机  ";
        }
        if (this.Checkbox4.Checked == true)
        {
            like += "游戏  ";
        }
这里可以换成用CheckBoxList
#4
virusswb2008-02-25 14:10
然后使用foreach循环,如果选中,链接名称
#5
秋日2008-02-27 10:51
楼上说的有道理。顶一下!
#6
1916381412008-02-27 22:36
我觉得使用Dropdownlist更好
this.dropdownlist.selecteditem.text
就可以得出他所喜欢的爱好。。
1