Click here to Skip to main content
16,005,290 members
Please Sign up or sign in to vote.
3.11/5 (2 votes)
See more:
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 ..
Posted
Updated 14-May-15 19:32pm
v2
Comments
anpxbkhn 15-May-15 0:48am    
Show your code, maybe I can help

Move set variables codes from event button click to SendHTMLMail()
C#
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;
 
Share this answer
 
v2
create a class declare variables and fill the text box values in to class variables and pass that class object to MailBody.cs class
 
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