Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# jQuery对话框发送电子邮件_C#_Jquery_Html_Asp.net_Email - Fatal编程技术网

C# jQuery对话框发送电子邮件

C# jQuery对话框发送电子邮件,c#,jquery,html,asp.net,email,C#,Jquery,Html,Asp.net,Email,有点奇怪的问题。我试图从jQuery对话框发送一封电子邮件,但似乎我一直在将输入中的值发送到hiddenfields以便能够发送 这是我使用的jQuery javascript function sendEmail() { $("#email").dialog({ modal: true, width: 550 }); } 这是is使用的div HTML <div class="popUpStyle" title="Sen

有点奇怪的问题。我试图从jQuery对话框发送一封电子邮件,但似乎我一直在将输入中的值发送到hiddenfields以便能够发送

这是我使用的jQuery

javascript

function sendEmail() {
   $("#email").dialog({
       modal: true,
       width: 550          
    });
  }
这是is使用的div

HTML

<div class="popUpStyle" title="Send Email" id="email" style="display: none">
        <asp:Label ID="lblTo" runat="server" Text="To: "></asp:Label><asp:Label runat="server" ID="lblSendTo" Text=""></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="lblFrom" runat="server" Text="From: "></asp:Label><asp:Label runat="server" ID="lblSendFrom" Text="Training.Registration@JeffWyler.com"></asp:Label>
        <br />
        <asp:Label ID="lblSubject" runat="server" Text="Subject: "></asp:Label><input id="tbSubject" type="text"/>
        <br />
        <asp:Label ID="lblBody" runat="server" Text="Message:"></asp:Label>
        <br />
        <input ID="tbMessage" runat="server" />
        <br />
        <asp:Button ID="btnSend" runat="server" Text="Send" Width="50px" Font-Size="smaller" UseSubmitBehavior="false" OnClick="btnSend_Click" />
    </div>

问题是,我不知道如何将输入中的值写入服务器端的hiddenfield或其他控件以发送电子邮件。我知道一旦单击“发送”按钮,这些值就会被删除。这确实会发送电子邮件(在另一个按钮单击时,我会将lblSendTo显示为收件人电子邮件地址),但没有需要输入的字段,例如邮件的主题和正文。非常感谢您的帮助

您只需要使用asp文本框,其中的文本应该在服务器端可用

根据您的评论:请注意更新

明显的问题是对话框没有附加到表单中,因此在回发期间,文本框中的值不会发送到请求中

    <a href="javascript:void(0)" onclick="sendEmail()">Send email</a> // Assuming this is the anchor used to open the dailog, you can change it your way

    <asp:Label ID="lblSubject" runat="server" Text="Subject: "></asp:Label>
    <asp:TextBox ID="tbSubject" runat="server" />
    <br />
    <asp:Label ID="lblBody" runat="server" Text="Message:"></asp:Label>
    <br />
    <asp:TextBox ID="tbMessage" runat="server" />
    <asp:Button ID="btnSend" runat="server" Text="Send" Width="50px" Font-Size="smaller" UseSubmitBehavior="false" OnClick="btnSend_Click"  />
现在是剧本

   jQuery(document).ready(function () { // create the dialog right when the document is ready
     jQuery("#email").dialog({
       autoOpen: false,
       modal: true,
       width: 550          
     });
     jQuery("#email").parent().appendTo(jQuery("form:first")); // This will append the dialog to the form ensuring values are sent during postback.
   });

   function sendEmail() {
    jQuery('#email').dialog('open'); // Open the dialog now
    return false;
   }

你想在code behind的文本框中输入主题和消息吗?Sorta,输入在div中,id=“email”。我知道我无法直接从jquery发送电子邮件,因为发送电子邮件是一项服务器端功能。因此,我在“电子邮件”弹出窗口中显示输入主题和消息。我假设我必须做的是,将输入中的这些值保存到hiddenfield,然后能够从服务器端发送主题和消息?为什么需要hiddenfield?可以使用ajax和page方法发送邮件。我尝试过asp文本框。在测试过程中,我一直在发送空白的受试者和身体信息。我在搜索时收集到的信息是,按钮发回,但在发送之前会删除文本框中的值。好的,何时调用此sendmail()函数,我的意思是单击哪些按钮?您是顶级diggity。我所需要的只是parent().appendTo行。伟大的工作,感谢所有的帮助!
    msg.To.Add(new MailAddress(lblSendTo.Text));
    msg.From = new MailAddress("Training.Registration@example.com");
    msg.Subject = tbSubject.Text;
    msg.Priority = MailPriority.High;
    msg.Body = tbMessage.Text;
   jQuery(document).ready(function () { // create the dialog right when the document is ready
     jQuery("#email").dialog({
       autoOpen: false,
       modal: true,
       width: 550          
     });
     jQuery("#email").parent().appendTo(jQuery("form:first")); // This will append the dialog to the form ensuring values are sent during postback.
   });

   function sendEmail() {
    jQuery('#email').dialog('open'); // Open the dialog now
    return false;
   }