如何在asp.net中添加文本框值 [英] how to add textbox values in asp.net

查看:160
本文介绍了如何在asp.net中添加文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我添加文本框值

我的代码有错误

please help me adding textbox values

my code is having error

protected void TextBox11_TextChanged(object sender, EventArgs e)
    {
        if((!string.IsNullOrEmpty(TextBox6.Text)) && (!string.IsNullOrEmpty(TextBox7.Text)) && (!string.IsNullOrEmpty(TextBox8.Text)) && (!string.IsNullOrEmpty(TextBox9.Text)) && (!string.IsNullOrEmpty(TextBox10.Text)) && (!string.IsNullOrEmpty(TextBox11.Text)))
        {
            TextBox12.Text = (Convert.ToInt32(TextBox6.Text) + Convert.ToInt32(TextBox7.Text)) + (Convert.ToInt32(TextBox8.Text) + Convert.ToInt32(TextBox9.Text)) + (Convert.ToInt32(TextBox10.Text) + Convert.ToInt32(TextBox11.Text)).ToString();
        }
    }


我想添加6个文本框值并在只读textbox7中显示,请提前帮助我,谢谢朋友们帮助我plz


i want to add 6 textbox values and display in read only textbox7 please help me thanks in advance friends help me plz

推荐答案

我成功了,但我做的很少出错从int转换为字符串,并且正确的代码在下面

if((!string.IsNullOrEmpty(TextBox6.Text))&&(!string.IsNullOrEmpty(TextBox7.Text))&&(!string.IsNullOrEmpty(TextBox8.Text))&&(!string.IsNullOrEmpty(TextBox9.Text))&&(! (!string.IsNullOrEmpty(TextBox10.Text))&&(!string.IsNullOrEmpty(TextBox11.Text)))
{
TextBox12.Text =(((Convert.ToInt32(TextBox6.Text)+ Convert.ToInt32(TextBox7.Text))+(Convert.ToInt32(TextBox8.Text)+ Convert.ToInt32(TextBox9.Text))+(Convert.ToInt32( TextBox10.Text)+ Convert.ToInt32(TextBox11.Text))).ToString();
}
i got it working i had did little error that converting fro int to string and correct code is below

if((!string.IsNullOrEmpty(TextBox6.Text)) && (!string.IsNullOrEmpty(TextBox7.Text)) && (!string.IsNullOrEmpty(TextBox8.Text)) && (!string.IsNullOrEmpty(TextBox9.Text)) && (!string.IsNullOrEmpty(TextBox10.Text)) && (!string.IsNullOrEmpty(TextBox11.Text)))
{
TextBox12.Text = ((Convert.ToInt32(TextBox6.Text) + Convert.ToInt32(TextBox7.Text)) + (Convert.ToInt32(TextBox8.Text) + Convert.ToInt32(TextBox9.Text)) + (Convert.ToInt32(TextBox10.Text) + Convert.ToInt32(TextBox11.Text))).ToString();
}


这篇关于如何在asp.net中添加文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆