<div class="row">
<label for="email">E-mail Address</label>
<div class="col">
<div class="text"><asp:TextBox ID="TextBox2" runat="server"
onchange="javascript:updateHiddenField();"></asp:TextBox><asp:HiddenField ID="HiddenField1"
runat="server" />
</div>
<span>Find e-mail on <a href="#">My Address Book</a> / <a href="#">Contacts</a></span>
<span>Find e-mail on
<asp:HyperLink ID="HyperLink1" runat="server">Facebook Profile</asp:HyperLink></span>
</div>
</div>
<div class="row">
<label>Invite Type</label>
<div class="col">
<div class="inner-row">
<asp:RadioButton runat="server" ID="r1" Checked="true" GroupName="r"
/>
<label for="id-1"><em>Personalized</em> - Add a personal note to your invitation. This invite type will let your friend know of your identity and will include your personal note</label>
</div>
<div class="inner-row">
<asp:RadioButton runat="server" ID="r2" GroupName="r" />
<label for="id-2"><em>Anonymous</em> - Sending an invite anonymously will not reveal your indentity to your friend.</label>
</div>
</div>
</div>
<div class="row">
<label for="message">Personal Note</label>
<div class="col">
<div class="textarea">
<div class="textarea-holder">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="10"
Columns="30" onchange="javascript:updateHiddenField1();"></asp:TextBox><asp:HiddenField
ID="HiddenField2" runat="server" />
</div>
</div>
<span class="text-note">Including a note is optional, but isn’t<br />personalized messages always nice :)</span>
</div>
</div>
<asp:LinkButton ID="LinkButton6" runat="server" onClick="LinkButton6_Click" CssClass="btn-send"></asp:LinkButton>
这是我的 aspx 代码,我试图先从文本框传输值,然后传输到隐藏字段,然后是代码隐藏
<script type="text/javascript">
function updateHiddenField() {
document.getElementById('HiddenField1').value = document.getElementById('TextBox2').value;
}
function updateHiddenField1() {
document.getElementById('HiddenField2').value = document.getElementById('TextBox1').value
}
</script>
当我这样做时,值会显示出来alert(document.getElementById('HiddenField1').value);
但是它们不会传递给代码隐藏
public void LinkButton6_Click(object sender, EventArgs e) {
try{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.Subject = "";
mail.Body = HiddenField1.Value;
mail.To.Add(HiddenField2.Value);
////send the message
System.Net.Mail.SmtpClient mySmtpClient = new System.Net.Mail.SmtpClient();
System.Net.NetworkCredential myCredential = new System.Net.NetworkCredential("","");
//mySmtpClient.Port="25";
mySmtpClient.Host = "";
mySmtpClient.UseDefaultCredentials = false;
mySmtpClient.Credentials = myCredential;
mySmtpClient.Send(mail);
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
编辑:
我试过使用
mail.Body = TextBox2.Text; mail.To.Add(TextBox1.Text);
我试过没有 UpdatePanel
代码在 CSS 弹出窗口中,这是主要问题
正如建议我使用 html 按钮来调用 javascript 函数
function btn_click() {
var email = document.getElementById('HiddenField1').value;
var body = document.getElementById('HiddenField2').value;
}
我如何将此值作为我在 Asp.net 中的凭据传递
请帮忙