RadAjaxPanel working only after first postback

Posted by Community Admin on 04-Aug-2018 10:55

RadAjaxPanel working only after first postback

All Replies

Posted by Community Admin on 18-May-2012 00:00

Hi Experts,

I'm currently exploring RadAjaxPanel, developing on sharepoint custom webpart. 

And I am having issue whereby the AjaxPanel will only work after the first postback, before that the whole page refreshes upon the btnSearchUser click event in the ModalPopup for the AddressBook, After that it works fine.

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EmailToUserControl.ascx.cs" Inherits="PQWS.EmailTo.EmailToUserControl" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<link rel="stylesheet" type="text/css" href="/_layouts/PQWS/CSS/standard.css" />




<link rel="Stylesheet" type="text/css" href="/_Layouts/PQWS/css/tables.css" />
 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function invokeAjaxRequest()
            $find("<%= radAddressBook.ClientID%>").ajaxRequestWithTarget("<%= radAddressBook.UniqueID %>", "SearchFunction");
            return false;
       
    </script>
</telerik:RadCodeBlock>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="gdvSearchUser">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gdvSearchUser" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>


<asp:Table runat="server" ID="tblMain">
<asp:TableRow><asp:TableCell>
<table>
<tr>
<td class="tbl-odd-up">
To  :
</td>
<td class="tbl-even-up" colspan ="2">
<asp:TextBox runat="server" ID="txtEmailTo" Width="80%"></asp:TextBox>
<asp:ImageButton runat="server" ID="btnEmailToSearch" Text="Search User" ImageUrl="/_layouts/PQWS/css/user_lookup.gif" />
<%--<asp:RegularExpressionValidator ID="vldEmailToValid" runat="server" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txtEmailTo" ErrorMessage="\nInvalid Email Format"></asp:RegularExpressionValidator>
--%><%--<asp:RequiredFieldValidator runat="server" ID="vldEmailToNotEmpty" ControlToValidate="txtEmailTo"></asp:RequiredFieldValidator>--%>
</td>
</tr>
<tr>
<td class="tbl-odd-up">
CC :
</td>
<td class="tbl-even-up" colspan="2">
<asp:TextBox runat="server" ID="txtEmailCC" width="80%">
</asp:TextBox>
<%--<asp:RegularExpressionValidator ID="vldEmailCCValid" runat="server" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="txtEmailCC" ErrorMessage="\nInvalid Email Format"></asp:RegularExpressionValidator>--%>
<%--<asp:RequiredFieldValidator runat="server" ID="vldEmailCCNotEmpty" ControlToValidate="txtEmailCC"></asp:RequiredFieldValidator>--%>
</td>
</tr>
<tr>
<td class="tbl-odd-up">
Subject : 
</td>
<td class="tbl-even-up" colspan="2">
<asp:TextBox runat="server" ID="txtEmailSubject" Width="80%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="tbl-odd-up">
Attachment(s) :
</td>
<td class="tbl-even-up" colspan="2">
<telerik:RadUpload ID="rduAttachment" Runat="server" overwriteexistingfiles="true" />
</td>
</tr>
<tr>
<td class="tbl-even-up" colspan = "3">
   <telerik:RadEditor ID="editorEmail" runat="server" StripFormattingOnPaste ="AllExceptNewLines">
                        <Tools>
                                                <telerik:EditorToolGroup>
                                                    <telerik:EditorTool Name="FontName" />
                                                    <telerik:EditorTool Name="FontSize" />
                                                    <telerik:EditorTool Name="Bold" />
                                                    <telerik:EditorTool Name="Italic" />
                                                    <telerik:EditorTool Name="Underline" />
                                                    <telerik:EditorTool Name="StrikeThrough" />
                                                    <telerik:EditorTool Name="JustifyLeft" />
                                                    <telerik:EditorTool Name="JustifyCenter" />
                                                    <telerik:EditorTool Name="JustifyRight" />
                                                    <telerik:EditorTool Name="JustifyFull" />
                                                    <telerik:EditorTool Name="Indent" />
                                                    <telerik:EditorTool Name="Outdent" />
                                                    <telerik:EditorTool Name="BackColor" />
                                                    <telerik:EditorTool Name="ForeColor" />
                                                    <telerik:EditorTool Name="Undo" />
                                                    <telerik:EditorTool Name="Redo" />
                                                    <telerik:EditorTool Name="InsertOrderedList" />
                                                    <telerik:EditorTool Name="InsertUnorderedList" />
                                                    <telerik:EditorTool Name="InsertTable" />
                                                </telerik:EditorToolGroup>
                                            </Tools>
                        </telerik:RadEditor>
                   </td>
</tr>
<tr>
<td class="tbl-odd-up" colspan="3" align="center">
<asp:Button runat="server" ID="btnEmail" Text="Send Email" 
        onclick="btnEmail_Click" />
</td>
</tr>
</table>
<cc1:ModalPopupExtender ID="btnSearch_ModalPopupExtender" runat="server" 
    TargetControlID="btnEmailToSearch"  BackgroundCssClass="GrayedOut" PopupControlID="pnlEmailTo" CancelControlID="btnEmailToCancel">
</cc1:ModalPopupExtender>
<asp:Panel runat="server" ID="pnlEmailTo">


<table>
<tr>
<td class="tbl-odd-up">
Search:
</td>
<td class="tbl-even-up">
<asp:TextBox runat="server" ID="txtSearchUser"></asp:TextBox>
<%--<asp:Button runat="server" ID="btnSearchUser" Text="Search" OnClientClick="invokeAjaxRequest();return false;" />--%>
<input type="button" onclick="invokeAjaxRequest();" value="Search"/>
</td>
</tr>
<tr>
<td colspan="2">
<telerik:RadAjaxPanel ID="radAddressBook" runat="server" OnAjaxRequest="radAddressBook_AjaxRequest">
<asp:GridView runat="server" ID="gdvSearchUser" AutoGenerateColumns="false" Width="100%">
   <RowStyle CssClass="GridView_Row" />
                        <HeaderStyle CssClass="GridView_Header" />
                        <AlternatingRowStyle CssClass="GridView_AlternateRow" />
                        <FooterStyle CssClass="GridView_Footer" />
                         <Columns>
                         <asp:TemplateField HeaderText="Select">
                                <ItemTemplate>
                                   <asp:CheckBox runat="server" ID="chkSelect" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="No">
                                <ItemTemplate>
                                    <%#Container.DataItemIndex + 1%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Company" DataField="Name" />
                            <asp:TemplateField HeaderText="Email">
                                <ItemTemplate>
                                   <asp:Label runat="server" ID="lblEmail" text='<%# Eval("Address")%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
</asp:GridView>
</telerik:RadAjaxPanel>
</td>
</tr>
<tr>
<td colspan="2" class="tbl-odd-up" align="center">
<asp:Button runat="server" id="btnAdd" Text="Add to Main" OnClick="btnAdd_Click" />
<asp:Button runat="server" id="btnEmailCCAdd" Text="Add to CC" OnClick="btnEmailCCAdd_Click" />
<asp:Button runat="server" id="btnEmailToCancel" Text="Cancel" />
</td>
</tr>
</table>


</asp:Panel>
</asp:TableCell></asp:TableRow>
</asp:Table>
<asp:Table runat="server" ID="tblError">
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server" ID="lblError"></asp:Label>
<asp:Label runat="server" ID="lblTrace"></asp:Label>
</asp:TableCell>
</asp:TableRow>
</asp:Table>




using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Mail;
using System.Web.SessionState;
using System.IO;
using System.Data;
using System.Text;
using Telerik.Web.UI;
using SPMuuLibrary.SharePoint;
using SPMuuLibrary.Logger;
using SPMuuLibrary.Database;
using Microsoft.SharePoint;
using PQWSLib;


namespace PQWS.EmailTo

    public partial class EmailToUserControl : SPMuuLibrary.SPMuuBaseClass
   
        DBTool objDB;
        Button btnError = null;
        protected void Page_Init(object sender, EventArgs e)
       
            try
           
                Logger = new LogTool("EmailToUserControl"); 
                ErrMsg = "Error caught at EmailToUserControl.";
           
            catch (Exception ex)
           
                Exception exception = new Exception(ErrMsg + "Page_Init(): ", ex);
                ErrorHandling("General Error Message", exception, ref this.tblMain,
                              ref this.tblError, ref btnError, ref this.lblTrace, ref this.lblError);


                if (Logger.IsErrorEnabled()) Logger.Error(ErrMsg + "Page_Init(): ", ex);
           
       
        protected void Page_Load(object sender, EventArgs e)
       
            try
           
                objDB = new DBTool();
                string strBody;
                editorEmail.EditModes = Telerik.Web.UI.EditModes.Design;
                if (!IsPostBack)
               
                    string strTemplateType = Request.QueryString["TemplateID"];
                    string strCRN = Request.QueryString["CRN"];
                    string strSubject = "";
                    DataTable dt = new DataTable();
                    clsEmail objEmail = new clsEmail(objDB);
                    objDB.OpenSQLConnection();
                    dt = objEmail.SelectEmailAgency("");
                    gdvSearchUser.DataSource = dt;
                    gdvSearchUser.DataBind();


                    dt = objEmail.SelectEmailTemplate(" Active = 'Y' AND TemplateID = " + DBTool.Parse(strTemplateType));
                                        
                    strSubject = dt.Rows[0]["Subject"].ToString();
                    txtEmailSubject.Text = strSubject.Replace("CRN", "" + strCRN + "");
                    strBody = dt.Rows[0]["Body"].ToString();


                    //Clear Datatable to re-use
                    dt.Clear();


                    //Get Case Subject and Email Receive date to be populated into Email
                    dt = objEmail.SelectCaseInfo("A.CRN = " + DBTool.Parse(strCRN));
                    txtEmailSubject.Text += dt.Rows[0]["CaseTitle"].ToString();
                    strBody = strBody.Replace("Query Send in Date", dt.Rows[0]["EmailReceivedDate"].ToString());
                    strBody = strBody.Replace("CRN", dt.Rows[0]["CRN"].ToString());
                    strBody = strBody.Replace("Enquirer Name", dt.Rows[0]["Name"].ToString());


                    editorEmail.Content = strBody;


                    //To check if need to auto populate email receipent
                    if (strTemplateType == SPMuuLibrary.Common.UtilTool.GetConfigValue("PopulateEmailAddress"))
                   
                        txtEmailTo.Text = dt.Rows[0]["Email"].ToString();
                        txtEmailTo.Enabled = false;
                        btnAdd.Visible = false;
                   
               
           
            catch (Exception ex)
           
                Exception exception = new Exception(ErrMsg + "Page_Load(): ", ex);
                ErrorHandling("General Error Message", exception, ref this.tblMain,
                              ref this.tblError, ref this.btnError, ref this.lblTrace, ref this.lblError);


                if (Logger.IsErrorEnabled()) Logger.Error(ErrMsg + "Page_Load(): ", ex);
           
            finally
           
                if (objDB != null)
               
                    objDB.Dispose();
               
           
       


        protected void btnEmail_Click(object sender, EventArgs e)
       
            try
           
                string strSenderName = "";
                string strTemplateType = "";
                string strFileName = "";
                string strEmailBody = "";
                string strTotalFileUpload = "";


                //Instantiate clsAudit for audit logging
                clsAudit objAudit = new clsAudit();
                //Instantiate clsEmail to get Case Enquirer details and Case Desc
                objDB = new DBTool();
                objDB.OpenSQLConnection();
                clsEmail objEmail = new clsEmail(objDB);
                clsUserProfile objUserProfile = new clsUserProfile();
                DataTable dt = new DataTable();


                if (txtEmailTo.Text != "" && txtEmailSubject.Text != "")
               
                    MailMessage mailMsg = new MailMessage();
                    mailMsg.From = SPMuuLibrary.Common.UtilTool.GetConfigValue("EmailAddress");
                    mailMsg.To = txtEmailTo.Text;
                    if (txtEmailCC.Text != "")
                   
                        mailMsg.Cc = txtEmailCC.Text;
                   
                    mailMsg.Subject = txtEmailSubject.Text;


                    //Attach attachment from database to Email.
                    dt = objEmail.SelectAttachment(" CRN = " + DBTool.Parse(Request.QueryString["CRN"]));
                    foreach (DataRow dr in dt.Rows)
                   
                        byte[] byteFile;
                        byteFile = (byte[])dr["ContentFile"];


                        strFileName = dr["FileName"].ToString();
                        FileStream objFileStream = new FileStream(SPMuuLibrary.Common.UtilTool.GetConfigValue("TempUploadLocation") + strFileName, FileMode.Create, FileAccess.Write);
                        objFileStream.Write(byteFile, 0, byteFile.Length);
                        objFileStream.Close();
                        MailAttachment attach = new MailAttachment(SPMuuLibrary.Common.UtilTool.GetConfigValue("TempUploadLocation") + strFileName);
                        mailMsg.Attachments.Add(attach);
                        if (strTotalFileUpload == "")
                       
                            strTotalFileUpload = strFileName;
                       
                        else
                       
                            strTotalFileUpload += "," + strFileName;
                       
                   
                    dt.Clear();


                    //Dump attachment to temp folder on server before sending out with email.
                    if (rduAttachment.UploadedFiles.Count != 0)
                   
                        foreach (UploadedFile attFile in rduAttachment.UploadedFiles)
                       
                            strFileName = Path.GetFileName(attFile.FileName);
                            /* Save the file on the server */
                            attFile.SaveAs(SPMuuLibrary.Common.UtilTool.GetConfigValue("TempUploadLocation") + strFileName, true);
                            /* Create the email attachment with the uploaded file */
                            MailAttachment mailAttach = new MailAttachment(SPMuuLibrary.Common.UtilTool.GetConfigValue("TempUploadLocation") + strFileName);
                            /* Attach the newly created email attachment */
                            mailMsg.Attachments.Add(mailAttach);
                            if (strTotalFileUpload == "")
                           
                                strTotalFileUpload = strFileName;
                           
                            else
                           
                                strTotalFileUpload += "," + strFileName;
                           
                       
                   
                    if (editorEmail.Content != "")
                   
                        mailMsg.BodyFormat = MailFormat.Html;
                        strTemplateType = Request.QueryString["TemplateID"];


                        dt = objEmail.SelectCaseInfo(" A.CRN = " + DBTool.Parse(Request.QueryString["CRN"]));
                        //Replace Email Body and read into Mail.Body
                        if (strTemplateType == SPMuuLibrary.Common.UtilTool.GetConfigValue("SendToOtherAgency"))
                       
                            DataTable dtAgency = new DataTable();
                            //Check if Email address exist in address book, if not yes, replace template text
                            dtAgency = objEmail.SelectEmailAgency(" ADDRESS IN('" + txtEmailTo.Text.Replace(";", "','") + "') ");
                            foreach (DataRow dr in dtAgency.Rows)
                           
                                if (strSenderName == "")
                               
                                    strSenderName = dr["Name"].ToString();
                               
                                else
                               
                                    strSenderName += ", " + dr["Name"].ToString();
                               
                           
                            strEmailBody = editorEmail.Content.Replace("agency name", strSenderName);
                            mailMsg.Body = strEmailBody;
                       
                        else
                       
                            strEmailBody = editorEmail.Content;
                       
                        //Append Name, Contact Number, Sender Email, Case Subject and Case Description below Email.
                        if (!string.IsNullOrEmpty(dt.Rows[0]["Name"].ToString()))
                       
                            strEmailBody += "<br /><br /><br />Name : " + dt.Rows[0]["Name"].ToString();
                       
                        if (!string.IsNullOrEmpty(dt.Rows[0]["ContactNumber"].ToString()))
                       
                            strEmailBody += "<br />Contact Number : " + dt.Rows[0]["ContactNumber"].ToString();
                       
                        if (!string.IsNullOrEmpty(dt.Rows[0]["Email"].ToString()))
                       
                            strEmailBody += "<br />Email : " + dt.Rows[0]["Email"].ToString();
                       
                        if (!string.IsNullOrEmpty(dt.Rows[0]["CaseTitle"].ToString()))
                       
                            strEmailBody += "<br />Subject : " + dt.Rows[0]["CaseTitle"].ToString();
                       
                        if (!string.IsNullOrEmpty(dt.Rows[0]["CaseDesc"].ToString()))
                       
                            strEmailBody += "<br /><br />" + dt.Rows[0]["CaseDesc"].ToString();
                       


                        mailMsg.Body = strEmailBody;
                   


                    /* Set the SMTP server and send the email with attachment */


                    SmtpMail.SmtpServer = SPMuuLibrary.Common.UtilTool.GetConfigValue("EmailSMTP");
                    SmtpMail.SmtpServer.Insert(0, SPMuuLibrary.Common.UtilTool.GetConfigValue("EmailSMTP"));
                    SmtpMail.Send(mailMsg);


                    //delete any file available
                    if (strTotalFileUpload != "")
                   
                        foreach (string strFile in strTotalFileUpload.Split(','))
                       
                            File.Delete(SPMuuLibrary.Common.UtilTool.GetConfigValue("TempUploadLocation") + strFile);
                       
                   
                    dt.Clear();
                    //Get UserID
                    string strUserName = "";
                    strUserName = SPContext.Current.Web.CurrentUser.LoginName;
                    strUserName = strUserName.Substring(strUserName.IndexOf('\\') + 1);
                    dt = objUserProfile.GetUserProfile(objDB, " LoginID = " + DBTool.Parse(strUserName));
                    if (strTemplateType == SPMuuLibrary.Common.UtilTool.GetConfigValue("SendHoldingReply"))
                   
                        objAudit.UpdateSendHoldingReplyAudit(Request.QueryString["CRN"], dt.Rows[0]["UserID"].ToString(), HttpContext.Current.Request.Url.AbsoluteUri, " CaseAuditID = " + Request.QueryString["CaseAuditID"]);
                   
                    else if (strTemplateType == SPMuuLibrary.Common.UtilTool.GetConfigValue("SendToOtherAgency"))
                   
                        objAudit.UpdateAssignOtherAgencyAudit(Request.QueryString["CRN"], dt.Rows[0]["UserID"].ToString(), txtEmailTo.Text, " CaseAuditID = " + Request.QueryString["CaseAuditID"]);
                   
                    else if (strTemplateType == SPMuuLibrary.Common.UtilTool.GetConfigValue("RequestForMoreInfo"))
                   
                        objAudit.UpdateRequestMoreInfoAudit(Request.QueryString["CRN"], dt.Rows[0]["UserID"].ToString(), HttpContext.Current.Request.Url.AbsoluteUri, " CaseAuditID = " + Request.QueryString["CaseAuditID"]);
                   
                    JSMsgBox("Email Successfully Sent!", "", true, false);
               
           
            catch (Exception ex)
           
                Exception exception = new Exception(ErrMsg + "btnEmail_Click(): ", ex);
                ErrorHandling("General Error Message", exception, ref this.tblMain,
                              ref this.tblError, ref this.btnError, ref this.lblTrace, ref this.lblError);


                if (Logger.IsErrorEnabled()) Logger.Error(ErrMsg + "btnEmail_Click(): ", ex);
           
            finally
           
                if (objDB != null)
               
                    objDB.Dispose();
               
           
       


        protected void radAddressBook_AjaxRequest(object sender, AjaxRequestEventArgs e)
       
            //Populate and rebind Address Book
            string strCondition = "";
            DataTable dt = new DataTable();
            try
           
                objDB = new DBTool();
                objDB.OpenSQLConnection();
                switch (e.Argument)
               
                    case "SearchFunction":
                        strCondition = txtSearchUser.Text;
                        clsEmail objEmail = new clsEmail(objDB);
                        if (strCondition != "")
                       
                            dt = objEmail.SelectEmailAgency(" Active = 'Y' AND (Name LIKE '%" + strCondition + "%' OR Address LIKE '%" + strCondition + "%')  ");
                       
                        else
                       
                            dt = objEmail.SelectEmailAgency("");
                       
                        gdvSearchUser.DataSource = dt;
                        gdvSearchUser.DataBind();
                        break;
                    default:
                        break;
               
           
            catch (Exception ex)
           
                throw new Exception(ErrMsg + "radAddressBook_AjaxRequest(): ", ex);
           
            finally
           
                if (objDB != null)
               
                    objDB.Dispose();
               
           
       


        protected void btnAdd_Click(object sender, EventArgs e)
       
            try
           
                btnSearch_ModalPopupExtender.Hide();
                Label lblSelectedEmail = new Label();
                string strSelectedEmail = "";
                foreach (GridViewRow dr in gdvSearchUser.Rows)
               
                    lblSelectedEmail.Text = "";
                    CheckBox chkSelect = (CheckBox)dr.FindControl("chkSelect");
                    if (chkSelect.Checked == true)
                   
                        if (strSelectedEmail != "")
                       
                            lblSelectedEmail = (Label)dr.FindControl("lblEmail");
                            strSelectedEmail += ";" + lblSelectedEmail.Text;
                       
                        else
                       
                            lblSelectedEmail = (Label)dr.FindControl("lblEmail");
                            strSelectedEmail = lblSelectedEmail.Text;
                       
                   
               
                if (strSelectedEmail != "")
               
                    if (txtEmailTo.Text == "")
                   
                        txtEmailTo.Text = strSelectedEmail;
                   
                    else
                   
                        txtEmailTo.Text += ";" + strSelectedEmail;
                   
               
           
            catch (Exception ex)
           
                Exception exception = new Exception(ErrMsg + "btnAdd_Click(): ", ex);
                ErrorHandling("General Error Message", exception, ref this.tblMain,
                              ref this.tblError, ref this.btnError, ref this.lblTrace, ref this.lblError);


                if (Logger.IsErrorEnabled()) Logger.Error(ErrMsg + "btnAdd_Click(): ", ex);
           
            finally
           
                if (objDB != null)
               
                    objDB.Dispose();
               
           
       


        protected void btnEmailCCAdd_Click(object sender, EventArgs e)
       
            try
           
                btnSearch_ModalPopupExtender.Hide();
                Label lblSelectedEmail = new Label();
                string strSelectedEmail = "";
                foreach (GridViewRow dr in gdvSearchUser.Rows)
               
                    lblSelectedEmail.Text = "";
                    CheckBox chkSelect = (CheckBox)dr.FindControl("chkSelect");
                    if (chkSelect.Checked == true)
                   
                        if (strSelectedEmail != "")
                       
                            lblSelectedEmail = (Label)dr.FindControl("lblEmail");
                            strSelectedEmail += ";" + lblSelectedEmail.Text;
                       
                        else
                       
                            lblSelectedEmail = (Label)dr.FindControl("lblEmail");
                            strSelectedEmail = lblSelectedEmail.Text;
                       
                   
               
                if (strSelectedEmail != "")
               
                    if (txtEmailCC.Text == "")
                   
                        txtEmailCC.Text = strSelectedEmail;
                   
                    else
                   
                        txtEmailCC.Text += ";" + strSelectedEmail;
                   
               
           
            catch (Exception ex)
           
                Exception exception = new Exception(ErrMsg + "btnEmailCCAdd_Click(): ", ex);
                ErrorHandling("General Error Message", exception, ref this.tblMain,
                              ref this.tblError, ref this.btnError, ref this.lblTrace, ref this.lblError);


                if (Logger.IsErrorEnabled()) Logger.Error(ErrMsg + "btnEmailCCAdd_Click(): ", ex);
           
            finally
           
                if (objDB != null)
               
                    objDB.Dispose();
               
           
       


        public void JSMsgBox(string message, string redirectPage, bool closeWin, bool StartupScriptMethod)
       
            StringBuilder strBuilder = new StringBuilder();


            strBuilder.Append("<script language='javascript'>");


            //message = message.Replace("'", "\'");
            //message = message.Replace(":", "\:");
            //message = message.Replace("vbCrLf", "\n");


            strBuilder.Append("alert('" + message + "');");


            if (redirectPage.Length > 0)
           
                strBuilder.Append("window.location='" + redirectPage + "';");
           


            if (closeWin)
           
                strBuilder.Append("window.close();");
           


            strBuilder.Append("</script>");


            if (StartupScriptMethod)
           
                Page.ClientScript.RegisterStartupScript(typeof(string), "Popup" + DateTime.Now.ToLongTimeString(), strBuilder.ToString());
           
            else
           
                Response.Write(strBuilder.ToString());
           
       
   


This thread is closed