I have created web-part form with sendMail function.
protected void btnSubmitForm_Click(object sender, EventArgs e)
{
SendEmail();
ClearFields();
}
But when page loads mail sends too(with the last fields data), not only by clicking button... Could someone knows solution? Thanks very much!
I have created CustomControl and added them to webpart. Web part i have added to the page layout using . Code Behind and html code is in the CustomControl:
protected void Page_Load(object sender, EventArgs e) {
if (SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
{
foreach (BaseValidator val in Page.GetValidators("Form"))
{
val.Enabled = false;
}
btnSubmitForm.Enabled = false;
}
}
protected void btnSubmitForm_Click(object sender, EventArgs e)
{
try
{
SendEmail();
}
catch (Exception ex)
{
ExceptionHelper.LogException(ex);
}
ClearFields();
}