如何在类文件中获取Textbox值 [英] How to fetch Textbox value in class file

查看:131
本文介绍了如何在类文件中获取Textbox值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的peoject.how中使用MailBody.cs类文件将特定页面的textbox,checkbox等值传递给我的类文件



cs file代码



公共字符串TxtInvoice

{

get

{

返回_TxtInvoice;

}

set

{

_TxtInvoice = value;

}

}

公共字符串txtEmail

{

get

{

返回_txtEmail;

}

设定

{

_txtEmail =值;

}

}

公共字符串lblMessage

{

get

{

返回_lblMessage;

}

设定

{

_lblMessage =价值;

}



按钮代码



protected void Button7_Click(object发件人,EventArgs e)

{

MailBody obj = new MailBody();

obj.TxtInvoice = TxtInvoice.Text;

obj.txtEmail = txtEmail.Text;

obj.lblMessage = lblMessage.Text;

SendHTMLMail();

}

public void SendHTMLMail()

{

MailBody obj = new MailBody();



string name;

string mobileNo;

string email;

string check_In;

string Check_out;

string roomType;

string RoomNum;

string Ammount;

obj.GetData(out name,out mobileNo ,out email,out check_In,out Check_out,out roomType,out RoomNum,out Ammount);

StreamReader re ader = new StreamReader(Server.MapPath(〜/ MailBody.html));

string readFile = reader.ReadToEnd();

string myString =;





========================== ===============

它传递null值..

I am using MailBody.cs class file in my peoject.how to pass values of textbox ,checkbox,etc from particular page to my class file

cs file code

public string TxtInvoice
{
get
{
return _TxtInvoice;
}
set
{
_TxtInvoice = value;
}
}
public string txtEmail
{
get
{
return _txtEmail;
}
set
{
_txtEmail = value;
}
}
public string lblMessage
{
get
{
return _lblMessage;
}
set
{
_lblMessage = value;
}

button code

protected void Button7_Click(object sender, EventArgs e)
{
MailBody obj = new MailBody();
obj.TxtInvoice = TxtInvoice.Text;
obj.txtEmail = txtEmail.Text;
obj.lblMessage = lblMessage.Text;
SendHTMLMail();
}
public void SendHTMLMail()
{
MailBody obj = new MailBody();

string name;
string mobileNo;
string email;
string check_In;
string Check_out;
string roomType;
string RoomNum;
string Ammount;
obj.GetData(out name, out mobileNo, out email, out check_In, out Check_out, out roomType, out RoomNum, out Ammount);
StreamReader reader = new StreamReader(Server.MapPath("~/MailBody.html"));
string readFile = reader.ReadToEnd();
string myString = "";


=========================================
It passes null Value ..

推荐答案

移动设置变量代码从事件按钮单击到SendHTMLMail()

Move set variables codes from event button click to SendHTMLMail()
protected void Button7_Click(object sender, EventArgs e)
 {
 MailBody obj = new MailBody();
 obj.TxtInvoice = TxtInvoice.Text;
 obj.txtEmail = txtEmail.Text;
 obj.lblMessage = lblMessage.Text;
 SendHTMLMail();
 }

public void SendHTMLMail()
 {
 MailBody obj = new MailBody();
 obj.TxtInvoice = TxtInvoice.Text;
 obj.txtEmail = txtEmail.Text;
 obj.lblMessage = lblMessage.Text;
 string name;
 string mobileNo;
 string email;
 string check_In;
 string Check_out;


创建一个类声明变量并填充文本框值in to class variables并将该类对象传递给MailBody.cs类
create a class declare variables and fill the text box values in to class variables and pass that class object to MailBody.cs class


这篇关于如何在类文件中获取Textbox值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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