1

I have an online form which is used to send emails of some receivers. I have a textbox which is prefilled with some email address. If for debug I put there some text strings (see image)

enter image description here

and press the send button (invia) I still see the real receivers in the tbReceivers.text field.

protected void btSend_Click(object sender, EventArgs e)
{        
    String txtPath = Path.Combine(Global.TxtPath, "ProssimoAllenamento.Txt");
    StreamWriter sw = new StreamWriter(txtPath);
    sw.Write(tbBody.Text);
    sw.Close();

    String strError;
           if(Email.Send(tbReceivers.Text,Global.eUserType.COACH,"",tbBody.Text, tbSubject.Text, fuAttachment, out strError))
        MessageBox.Show("Email inviata correttamente", this.Page, this);
    else
        MessageBox.Show("Errore invio email: " + strError , this.Page, this);        
} 

So by searching solution I found that I had to use an updatePanel, scriptmanager and include everything in a . But nothing happened. Following my html thanx for your help Patrick


<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" Inherits="Altro_Admin_Admin_Coach" Title="Admin Coach" CodeBehind="Admin_Coach.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

            <table style="width: 100%">
               <tr>
                    <td style="height: 22px; width: 48px"></td>
                   <td style="height: 22px; width: 730px">
                       <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="X-Large" Text="Prossimo allenamento"></asp:Label>
                   </td>
                   <td style="height: 22px; width: 730px">&nbsp;</td>
                   <td style="height: 22px; width: 730px">&nbsp;</td>
                   <td style="height: 22px"></td>
               </tr>
               <tr>
                   <td style="width: 48px; height: 22px"></td>
                   <td style="width: 730px; height: 22px"></td>
                   <td style="width: 730px; height: 22px">&nbsp;</td>
                   <td style="width: 730px; height: 22px">&nbsp;</td>
                   <td style="height: 22px"></td>
               </tr>
               <tr>
                   <td style="width: 48px">Destinatari</td>
                   <td style="width: 730px">
                       <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                       <asp:TextBox ID="tbReceivers" runat="server" Height="47px" Width="707px" Font-Size="X-Small" TextMode="MultiLine"></asp:TextBox>


                   </td>
                   <td style="width: 730px">&nbsp;</td>
                   <td style="width: 730px">&nbsp;</td>
                   <td>&nbsp;</td>
               </tr>
               <tr>
                   <td style="width: 48px; height: 29px">Oggetto</td>
                   <td style="width: 730px; height: 29px">
                       <asp:TextBox ID="tbSubject" runat="server" Height="21px" Width="707px"></asp:TextBox>
                   </td>
                   <td style="width: 730px; height: 29px">&nbsp;</td>
                   <td style="width: 730px; height: 29px">&nbsp;</td>
                   <td style="height: 29px"></td>
               </tr>
               <tr>
                   <td style="width: 48px; height: 11px"></td>
                   <td style="height: 11px; width: 730px">
                       <asp:TextBox ID="tbBody" runat="server" Height="344px" Width="707px" TextMode="MultiLine" Style="vertical-align: top;"></asp:TextBox>
                       <br />
                       <asp:FileUpload ID="fuAttachment" runat="server" BackColor="White" Width="715px" />
                   </td>
                   <td style="height: 11px; width: 730px">&nbsp;</td>
                  <td style="height: 11px; width: 730px">&nbsp;</td>
                   <td style="height: 11px"></td>
               </tr>
               <tr>
                   <td style="width: 48px; height: 41px">&nbsp;</td>
                   <td style="height: 41px; width: 730px">
                       <asp:Button ID="btSend" runat="server" Height="45px" OnClick="btSend_Click" Text="INVIA" Width="714px" />
                   </td>
                    <td style="height: 41px; width: 730px">&nbsp;</td>
                   <td style="height: 41px; width: 730px">&nbsp;</td>
                   <td style="height: 41px">&nbsp;</td>
               </tr>
           </table>
       </ContentTemplate>
   </asp:UpdatePanel>

Patrick
  • 3,073
  • 2
  • 22
  • 60
  • if you use UpdatePanel, try adding Postback Trigger for button click – techspider Dec 31 '15 at 14:51
  • Would you please tell me how to do it? I followed http://stackoverflow.com/questions/10577474/postback-trigger-for-button-inside-a-usercontrol-in-updatepanel and so added //ScriptManager1.RegisterPostBackControl(btSend); in the PageLoad event. But when hitting the button click the tbReceivers.Text is Always the same uncorrect. – Patrick Jan 01 '16 at 23:42

0 Answers0