<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代碼,我想從文本框第一傳輸值,然後hiddenfield然後代碼隱藏值不會從JavaScript傳遞給代碼隱藏asp.net?
<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
請憑據幫助
你爲什麼不乾脆用你的代碼隱藏文本框的值? – jrummell 2012-04-05 12:23:40
我試過它沒有工作相同的錯誤,所以嘗試使用這種相同的事情也發生在這裏以及 – 2012-04-05 12:24:29
這是在一個用戶控件或有任何其他可能不明顯從您的代碼示例? – jrummell 2012-04-05 12:26:52