You could use Settings
for this. In the projects properties, there is a page Settings
. You can enter strings there and give them a name. Create a string and call it UserEmail (The value you enter now will be the default value for new installations). In the Form where the value should be shown create a method that is called when the Form is loaded (perhaps called from Form_Load):
private void Init()
{
this.txtEmail.Text = Properties.Settings.Default.UserEmail;
}
Now you need to save the value. You could do this whenever the value changes or just, when the form closes. The following method could be called in both scenarios (perhaps Form_Closing):
private void Save()
{
Properties.Settings.Default.UserEmail = this.txtEmail.Text;
Properties.Settings.Default.Save();
}
This saves the value, that is currently entered in the TextBox to the setting, which will be loaded the next time the application starts.
In winforms, you could use below code on load,
Textbox.Text = "default text"
Example:
emailTextbox.Text = "abc@gmail.com"
passwordBox.Text = "123456"
First of all assign hardcode value for two textboxs, email and password in page load like below
protected void Page_Load(object sender, EventArgs e)
{
emailTextbox.Text = "youremail@gmail.com";
passwordTextbox.Text = "yourPassword";
}
After button btnSendEmail click Check follow
if(!string.IsNullOrEmpty(emailTextbox.Text)&&!string.IsNullOrEmpty(passwordTextbox.Text))
{
// write email sending code here
}
else
{
//warning message regarding email id and password is required
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.