This is a migrated thread and some comments may be shown as answers.

Dangerous Controls values clearance after back from popup windows

3 Answers 111 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ihab
Top achievements
Rank 1
Ihab asked on 01 Aug 2010, 02:21 PM
Hi,

actually i have a vague and dangerous problem regarding to use of normal scripted popups (not RadWindow)

in my scenario i have normal popup fires on button click from parent page wich has several controls of telerik and microsoft ajaxified with radAjaxManager.

however, in rear scenarios i am opening the popup page and doing some oporations such validation and data maniplulations (retrieval, storing)

once i back every thing will be ok till i save

the problem that controls in parent page still has its own data but on save debugger will see it values as null
one of strange behaviour that RadeDateControls successed to maintain the data

as part of problem solving i tried to replace microsoft textboxes with telerik ones but same is happining (loosing data on save as seen from debugger)

note opening the popup without any postback effort and back to parent window doesnt cause any problems...

please Help me,
Ihab - Dubai

3 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 02 Aug 2010, 11:35 AM
Ihab, if I were in your shoes, the first thing I would check is whether the parent page has its viewstate enabled. Next thing on the list is to make sure you do not rebind the controls on the form when you close the popup window or if you do, make sure that their bound container data is not empty.

Another thing that comes to mind is to see if you change the form data on the parent page with javascript code - you may lose the values if you open the popup and then postback when closed.

If you are still uncertain about the cause of the strange behavior, post the code from the main and popup pages to examine them and make some additional suggestions.

Kiara
0
Ihab
Top achievements
Rank 1
answered on 02 Aug 2010, 08:12 PM
hi kiara,

i checked my code
the parent page i think viewstate is enabled by default but i didnt mentioned in the html parent page
however i enabled it now EnableViewState="true" in page directive

for second point "on the list is to make sure you do not rebind the controls on the form when you close the popup window or if you do, make sure that their bound container data is not empty. "

after i close popup page by default server code will fire and directley page will load and all RadGrids_needDatasources will fires consequently


for third point "Another thing that comes to mind is to see if you change the form data on the parent page with javascript code - you may lose the values if you open the popup and then postback when closed"

yes i am change lable information in the parent page from attachments popup window to update how many attachmets page has

and i am not loosing data always
it s rearly do in vague scenarious related of postback on the popup as i think

however this is my code and please send me your email if is possible to send my hole project because page has many usercontrols and really i am facing critical situation now
<%@ Page ValidateRequest="false" Title="MIS - Request Form" Language="C#" MasterPageFile="~/SiteUser.master" AutoEventWireup="true" CodeFile="DTC_Request.aspx.cs" Inherits="UI_WebForms_Admin_Work_Order_DTC_Request" %>
 
<%@ Register assembly="RadComboBox.Net2" namespace="Telerik.WebControls" tagprefix="radC" %>
 
<%@ Register TagPrefix="radC" Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" %>
<%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %>
 
<%@ Register src="../../../UserControls/DTC_DDL_AnnouncementTypes.ascx" tagname="DTC_DDL_AnnouncementTypes" tagprefix="uc1" %>
 
<%@ Register src="../../../UserControls/DTC_SelectUser.ascx" tagname="DTC_SelectUser" tagprefix="uc2" %>
<%@ Register src="../../../UserControls/DTC_SelectUsersList.ascx" tagname="DTC_SelectUsersList" tagprefix="uc3" %>
<%@ Register src="../../../UserControls/DTC_DDL_Importance.ascx" tagname="DTC_DDL_Importance" tagprefix="uc4" %>
 
<%@ Register src="../../../UserControls/DTC_ddl_RequestModes.ascx" tagname="DTC_ddl_RequestModes" tagprefix="uc5" %>
<%@ Register src="../../../UserControls/DTC_ddl_Status.ascx" tagname="DTC_ddl_Status" tagprefix="uc6" %>
<%@ Register src="../../../UserControls/DTC_ddl_Priorities.ascx" tagname="DTC_ddl_Priorities" tagprefix="uc7" %>
<%@ Register src="../../../UserControls/DTC_ddl_SubCategories.ascx" tagname="DTC_ddl_SubCategories" tagprefix="uc8" %>
<%@ Register src="../../../UserControls/DTC_ddl_Impacts.ascx" tagname="DTC_ddl_Impacts" tagprefix="uc9" %>
<%@ Register src="../../../UserControls/DTC_ddl_RequestTypes.ascx" tagname="DTC_ddl_RequestTypes" tagprefix="uc10" %>
 
<%@ Register src="../../../UserControls/DTC_btn_Attachments.ascx" tagname="DTC_btn_Attachments" tagprefix="uc12" %>
 
<%@ Register src="../../../UserControls/DTC_SelectUser_Details.ascx" tagname="DTC_SelectUser_Details" tagprefix="uc11" %>
 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHoder1" Runat="Server" >
 
    <script type="text/javascript" src="../../../js/Validate.js"></script>
<script type="text/javascript">
 
    function CaptureBackSpace2() {
    debugger
        if (window.event.keyCode == 8) {
            return ConfirmCancel();
        }
    }
    function DisableButton() {
        document.forms[0].submit();
        window.setTimeout("disableButton('" +
                   window.event.srcElement.id + "')", 0);
    }
 
    function disableButton(buttonID) {
        document.getElementById(buttonID).disabled = true;
    }
 
 
             
        var timer = null;
 
        function KeyUp()
        {
            if (timer != null)
            {
              clearTimeout(timer);
            }
            timer = setTimeout(LoadTable,500);
        }
 
      </script>
<script type="text/javascript" >
     
    function Validate(hdnError, ddl_Priorities, txtReq_ID, txtSummary, txtProblemDescription, rbAttendStatusYes, rbAttendStatusNo, ddl_Impacts) {
        validateMessage = "";
        flag = 1;
        CheckText(txtSummary, 'Summary ');
        //    CheckText(txtInitiator_ID, ' Initiator ');
        //    CheckText(txtRequester_ID, ' Requester ');
        CheckText(txtProblemDescription, 'Problem Description ');
        ValidateRadCombobox(ddl_Priorities, 'Priority');
        ValidateRadCombobox(ddl_Impacts, 'Impact');
 
        //CheckRadios(rbAttendStatusYes, rbAttendStatusNo, 'Attend Status');
 
        document.getElementById(hdnError).value = validateMessage;
        if (flag == 0) {
            openErrorDialog(validateMessage);
 
            return false;
        }
        else {
            document.getElementById("ctl00_ContentPlaceHoder1_btnUpdate").style.visibility = "hidden";
//            window.setTimeout("disableButton('" +  window.event.srcElement.id + "')", 0);
            return true;
        }
         
//        else {
//            if (document.getElementById("ctl00_ContentPlaceHoder1_btnUpdate").disabled == false) {
//                document.getElementById("ctl00_ContentPlaceHoder1_btnUpdate").disabled = true;
//                return true;
//            }
//            else {
//                return false;
//            }
//        }
    }
    function requestStart(sender, eventArgs) {
//        alert('Request start initiated by: ' + eventArgs.get_eventTarget());
        if (eventArgs.get_eventTarget().indexOf("btnUpdate") != -1)
            eventArgs.set_enableAjax(false);
    }
</script>
 
    <table>
<tr>
<td>
     
                                                        <table style="width: 100%">
                                                          
                                                            <tr>
                                                                <td>
     
                                                        <asp:Label ID="Label19" runat="server" CssClass="ContentText" ForeColor="Red"
                                                            Text="(*) Mandatory Fields"></asp:Label>
                                                             
                                                            <%--<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
        Skin="Windows7">
    </telerik:RadAjaxLoadingPanel>   
                                                            <telerik:RadAjaxManager EnableViewState="true" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
                                                                        ID="RadAjaxManager1" >
                                                                        <ClientEvents OnRequestStart="requestStart" />
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btnUpdate">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="btnUpdate" />
                    <telerik:AjaxUpdatedControl ControlID="DTC_btn_Attachments" />
                     
                     
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>--%>
                                                 </td>
                                                                <td align="right">
                                                                <table>
                                                                <tr>
                                                                <td>
                                                                <uc12:DTC_btn_Attachments ID="DTC_btn_Attachments" runat="server" />
                                                                 
                                                                </td>
                                                                <td>
                                                                <asp:ImageButton ID="btnCancel" runat="server" CausesValidation="False"
                                                            ImageUrl="~/UI/images/Cancel v3.jpg"
                                                            onclick="btnCancel_Click" ToolTip="Cancel" onclientclick="return ConfirmCancel();" />
                                                                </td>
                                                                <td>
                                                                <asp:ImageButton ID="btnUpdate" runat="server" CausesValidation="False"
                                                            ImageUrl="~/UI/images/save v2.JPG"
                                                            onclick="btnUpdate_Click" ToolTip="Save" />
                                                                </td>
                                                                 
                                                                </tr>
                                                                </table>
                                                                 
                                                         
     
                                                                    <asp:Button ID="btnAdvance" runat="server" onclick="btnAdvance_Click"
                                                                        Text="Advanced Request" Visible="False" />
                                                                </td>
                                                            </tr>
                                                        </table>
     
</td>
 
</tr>
<tr>
<td valign="top">
<asp:Panel ID="Panel1" runat="server" Font-Bold="False"
                                            GroupingText="Request Information"
        Height="100%" HorizontalAlign="Left"
                                            Width="100%" Font-Names="Tahoma">
                                            <table style="width: 100%; vertical-align: top;">
        <tr>
            <td 
                valign="top">
                                                        <asp:Label ID="Label121" runat="server" CssClass="ContentText" ForeColor="Red"
                                                            Text="*"></asp:Label>
            </td>
            <td                valign="Top">
                <asp:Label ID="Label70" runat="server" CssClass="ContentText" Text="Priority"></asp:Label>
            </td>
            <td valign="Top">
                                                        <asp:Label ID="Label119" runat="server" CssClass="ContentText" Text=":"></asp:Label>
            </td>
            <td  valign="Top" style="width: 136px">
                                <uc7:DTC_ddl_Priorities ID="DTC_ddl_Priorities" runat="server" />
            </td>
            <td valign="Top" width="100px">
                 </td>
            <td valign="Top">
                                                        <asp:Label ID="Label122" runat="server" CssClass="ContentText" Text="*"
                                                            ForeColor="Red"></asp:Label>
            </td>
            <td valign="Top">
                                                        <asp:Label ID="Label56" runat="server" CssClass="ContentText" Text="Impact"></asp:Label>
            </td>
            <td valign="Top">
                <asp:Label ID="Label72" runat="server" CssClass="ContentText" Text=":"></asp:Label>
            </td>
            <td valign="Top">
                <uc9:DTC_ddl_Impacts ID="DTC_ddl_Impacts" runat="server" />
            </td>
        </tr>
                                                <tr>
                                                    <td                                                      valign="top">
                                                         </td>
                                                    <td 
                                                        valign="Top">
                                                        <asp:Label ID="Label105" runat="server" CssClass="ContentText"
                                                            Text="Request ID" Visible="False"></asp:Label>
                                                    </td>
                                                    <td valign="Top">
                                                        <asp:Label ID="Label106" runat="server" CssClass="ContentText" Text=":"
                                                            Visible="False"></asp:Label>
                                                    </td>
                                                    <td style="width: 136px" valign="Top">
                                                        <telerik:RadTextBox ID="txtReq_ID" runat="server" CssClass="textbox" Height="15px"
                                                            ReadOnly="True" Text="" Visible="False"></telerik:RadTextBox>
                                                    </td>
                                                    <td valign="Top" width="100px">
                                                         </td>
                                                    <td valign="Top">
                                                         </td>
                                                    <td valign="Top">
                                                         </td>
                                                    <td valign="Top">
                                                         </td>
                                                    <td valign="Top">
                                                         </td>
                                                </tr>
                                                <tr>
                                                    <td 
                                                        valign="top">
                                                         </td>
                                                    <td 
                                                        valign="top">
                                                        <asp:Label ID="Label54" runat="server" CssClass="ContentText"
                                                            Text="Request Type" Visible="False"></asp:Label>
                                                    </td>
                                                    <td valign="top">
                                                        <asp:Label ID="Label116" runat="server" CssClass="ContentText" Text=":"
                                                            Visible="False"></asp:Label>
                                                    </td>
                                                    <td valign="top" style="width: 136px">
                                                        <uc10:DTC_ddl_RequestTypes ID="DTC_ddl_RequestTypes" runat="server"
                                                            Visible="False" />
                                                    </td>
                                                    <td valign="top" width="100px">
                                                         </td>
                                                    <td valign="top">
                                                         </td>
                                                    <td valign="top">
                                                         </td>
                                                    <td>
                                                         </td>
                                                    <td>
                                                         </td>
                                                </tr>
                                                <tr>
                                                    <td
                                                        valign="top">
                                                         </td>
                                                    <td
                                                        valign="top">
                                                         </td>
                                                    <td valign="top">
                                                         </td>
                                                    <td rowspan="2" valign="top" colspan="6">
                                                         </td>
                                                </tr>
        <tr>
            <td 
                valign="top">
                                                         </td>
            <td 
                valign="top">
                 </td>
            <td valign="top">
                                                         </td>
        </tr>
    </table>
                                            </asp:Panel>
</td>
 
</tr>
 
<tr>
<td>
<asp:Panel ID="Panel4" runat="server" Font-Bold="False"
                                            GroupingText="Requester Details"
        Height="100%" HorizontalAlign="Left"
                                            Width="100%" Font-Names="Tahoma"
        Visible="False">
    <table style="width: 100%; vertical-align: top;">
        <tr>
            <td valign="top">
                <asp:Label ID="Label60" runat="server" CssClass="ContentText"
                                            Text="Initiator"></asp:Label>
                      
            </td>
            <td valign="top">
                <asp:Label ID="Label64" runat="server"
                    CssClass="ContentText" Text=":"></asp:Label>
            </td>
            <td valign="top">
                <uc2:DTC_SelectUser ID="DTC_SelectUser" runat="server" />
            </td>
        </tr>
        <tr>
            <td valign="top" colspan="3">
                <uc11:DTC_SelectUser_Details ID="DTC_SelectRequester" runat="server" />
            </td>
        </tr>
    </table>
                                            </asp:Panel>
</td>
 
</tr>
 
<tr>
<td>
<asp:Panel ID="Panel3" runat="server" Font-Bold="False"
                                            GroupingText="Request Details" Height="100%" HorizontalAlign="Left"
                                            Width="100%" Font-Names="Tahoma">
    <table style="width: 100%; vertical-align: top;">
        <tr>
            <td valign="top">
                <asp:Label ID="Label117" runat="server" CssClass="ContentText" Text="*"
                    ForeColor="Red"></asp:Label>
            </td>
            <td valign="top">
                <asp:Label ID="Label23" runat="server" CssClass="ContentText" Text="Summary"></asp:Label>
            </td>
            <td valign="top">
                <asp:Label ID="Label107" runat="server" CssClass="ContentText" Text=":"></asp:Label>
            </td>
            <td valign="top">
                <telerik:RadTextBox ID="txtSummary" runat="server" CssClass="textbox" Height="39px"
                    MaxLength="250" Text=""
                    Width="600px" TextMode="MultiLine"></telerik:RadTextBox>
                <br />
                <asp:Label ID="lblTermName12" runat="server" CssClass="ContentText"
                    ForeColor="#3B738E" Text="* Enter 250 charecters maximum"></asp:Label>
            </td>
        </tr>
        <tr>
            <td valign="top">
                 </td>
            <td colspan="3" valign="top">
                <asp:Label ID="Label115" runat="server" CssClass="ContentText"
                    Text="Would you like to be present while attending to your problem ?"></asp:Label>
                <asp:RadioButton ID="rbAttendStatusYes" runat="server"
                    CssClass="ContentText" GroupName="AttendStatus" Text="Yes" />
                <asp:RadioButton ID="rbAttendStatusNo" runat="server" CssClass="ContentText"
                    GroupName="AttendStatus" Text="No" />
            </td>
        </tr>
        <tr>
            <td valign="top">
                 </td>
            <td colspan="3" valign="top">
                 </td>
        </tr>
        <tr>
            <td valign="top">
                <asp:Label ID="Label17" runat="server" CssClass="ContentText" ForeColor="Red"
                    Text="*"></asp:Label>
            </td>
            <td valign="top">
                <asp:Label ID="Label87" runat="server" CssClass="ContentText"
                    Text="Problem description"></asp:Label>
            </td>
            <td valign="top">
                <asp:Label ID="Label96" runat="server" CssClass="ContentText" Text=":"></asp:Label>
            </td>
            <td valign="top">
                <telerik:RadTextBox ID="txtProblemDescription" runat="server" CssClass="textbox"
                    Height="160px" MaxLength="5000" Text=""
                    TextMode="MultiLine" Width="600px"></telerik:RadTextBox>
                <br />
                <asp:Label ID="lblTermName13" runat="server" CssClass="ContentText"
                    ForeColor="#3B738E" Text="* Enter 5000 charecters maximum"></asp:Label>
            </td>
        </tr>
        <tr>
            <td valign="top">
                 </td>
            <td valign="top">
                 </td>
            <td valign="top">
                 </td>
            <td valign="top">
                 </td>
        </tr>
    </table>
                                            </asp:Panel>
</td>
 
</tr>
<tr>
<td>
 
                                                        <table style="width: 100%">
                                                            <tr valign="top">
                                                                <td>
     
                                                        <asp:Label ID="Label120" runat="server" CssClass="ContentText" ForeColor="Red"
                                                            Text="(*) Mandatory Fields" Visible="False"></asp:Label>
                                                 <asp:ImageButton ID="btnCancel0" runat="server" CausesValidation="False"
                                                            ImageUrl="~/UI/images/Cancel v3.jpg"
                                                            onclick="btnCancel_Click" ToolTip="Cancel" Visible="False" />
                                                        <asp:ImageButton ID="btnUpdate2" runat="server" CausesValidation="False"
                                                            ImageUrl="~/UI/images/save v2.JPG"
                                                            onclick="btnUpdate_Click" ToolTip="Save" Visible="False" />
     
                 
     
                                                                </td>
                                                                <td align="right">
                                                                <asp:Button ID="btnBacktoHome"
                        runat="server" onclick="btnBacktoHome_Click" Text="Back to home page" />
                                                                    <asp:Button ID="btnAdvance0" runat="server" onclick="btnAdvance_Click"
                                                                        Text="Advanced Request" />
                                                                </td>
                                                            </tr>
                                                        </table>
     
</td>
</tr>
</table>
    <table style="width: 100%; vertical-align: top;">
        <tr>
            <td valign="top">
 
 
<asp:HiddenField ID="hdnRequest_ID" Value='<%# Bind("Name") %>'  runat="server" />
 
 
 
 
 
 
 
<asp:HiddenField ID="hdnError" Value='<%# Bind("Name") %>'  runat="server" />
 
 
 
 
 
 
 
                                                    <%--<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                </telerik:RadAjaxManager>--%>
 
 
 
 
 
 
 
                                                    </td>
            <td valign="top">
                                                         </td>
            <td valign="top">
                                 </td>
            <td>
                 </td>
            <td>
                 </td>
            <td>
                 </td>
            <td>
                 </td>
            <td>
                 </td>
            <td>
                 </td>
        </tr>
    </table>
</asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.WebControls;
using System.Text;
public partial class UI_WebForms_Admin_Work_Order_DTC_Request : System.Web.UI.Page
{
    //Companies companies = new Companies();
    //Departments department = new Departments();
    //CompanyTypes companyTypes = new CompanyTypes();
    General general = new General();
    NotificationsSettings notSet = new NotificationsSettings();
    //Locations Location = new Locations();
    DTC_Users users = new DTC_Users();
    Requests requests = new Requests();
    //Requests_Actions requests_Actions = new Requests_Actions();
    Screen_Files screen_Files = new Screen_Files();
    private RadComboBox ddl_RequestTypes;
 
     
    private RadComboBox ddl_Priorities;
    private RadComboBox ddl_Impacts;
     
 
 
 
    protected void Page_Init(object Sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
        Response.Cache.SetNoStore();
    }
 
 
    protected void Page_Load(object sender, EventArgs e)
    {
        try{
        #region session
        if (Session["UserName"] == null)
        {
            if (Request.QueryString["User_ID"] != null)
            {
                #region Bind User Session
                users.User_ID = Request.QueryString["User_ID"];
                users.vBindUser();
                if (users.User_ID != "")
                {
                    Session["User_ID"] = users.User_ID;
 
                    Session["User_ID2"] = users.User_ID2;
                    if (users.Name.Trim() != "")
                    {
                        Session["UserName"] = users.Name;
                    }
                    else
                    {
                        if (users.Email.IndexOf("@") != -1)
                        {
                            Session["UserName"] = users.Email.Substring(0, users.Email.IndexOf("@"));
                        }
                    }
                    Session["UserType"] = users.TypeDesc;
                    Session["UserEmail"] = users.Email;
                    Session["UserDepartment"] = users.Dept_Name;
                    Session["UserLocation"] = users.Location_Name;
                    Session["UserJobTitle"] = users.JobTitle;
                    Session["UserCompany"] = users.CompanyName;
                    Session["UserCompany_ID"] = users.Company_ID;
                }
                else
                    Response.Redirect(ConfigurationManager.AppSettings["SessionExpired_Path"].ToString());
 
                #endregion
            }
            else
            {
                Response.Redirect(ConfigurationManager.AppSettings["SessionExpired_Path"].ToString());
            }
        }
        else
        {
            #region Audit Trail
            requests.UID = Session["User_ID"].ToString();//.Replace("\\", "_");
            #endregion
            if(Master.FindControl("lblUserName")!=null) ((Label)Master.FindControl("lblUserName")).Text = Session["FirstName"] != null ? General.sGetProcessedName(Session["FirstName"].ToString()) : "";
        }
        #endregion
             
        //RadAjaxManager1.AjaxSettings.AddAjaxSetting(btnUpdate, DTC_btn_Attachments.FindControl("File1"));
         
        ddl_RequestTypes = (RadComboBox)DTC_ddl_RequestTypes.FindControl("ddl_RequestTypes");
        
        ddl_Priorities = (RadComboBox)DTC_ddl_Priorities.FindControl("ddl_Priorities");
        ddl_Impacts = (RadComboBox)DTC_ddl_Impacts.FindControl("ddl_Impacts");
 
        //RadAjaxManager1.AjaxSettings.AddAjaxSetting(ddl_Impacts, ddl_Impacts);
             
                
        if (!Page.IsPostBack)
        {
            #region Security
            if (Session["UserType"].ToString() != "User" && Session["UserType"].ToString() != "Technician" && Session["UserType"].ToString() != "TM" && Session["UserType"].ToString() != "Guest")
            {
                Response.Redirect(ConfigurationManager.AppSettings["SessionExpired_Path"].ToString());
            }
            #endregion
            if (Session["UserType"].ToString() == "Technician" || Session["UserType"].ToString() == "TM")
            {
                Master.FindControl("SiteMapPath").Controls[0].Visible = false;
                Master.FindControl("SiteMapPath").Controls[1].Visible = false;
                Master.FindControl("SiteMapPath").Controls[2].Visible = false;
            }
            //ddl_Impacts.AutoPostBack = true;
            //StringBuilder sb = new StringBuilder();
            //sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
            //sb.Append("var oldPage_IsValid = Page_IsValid; var oldPage_BlockSubmit = Page_BlockSubmit;");
            //sb.Append("if (Page_ClientValidate('" + btnUpdate.ValidationGroup + "') == false) {");
            //sb.Append(" Page_IsValid = oldPage_IsValid; Page_BlockSubmit = oldPage_BlockSubmit; return false; }} ");
            //sb.Append("this.value = 'Processing...';");
            //sb.Append("this.disabled = true;");
            //sb.Append(ClientScript.GetPostBackEventReference(btnUpdate, null) + ";");
            //sb.Append("return true;");
            //string submit_button_onclick_js = sb.ToString();
            //btnUpdate.Attributes.Add("onclick", submit_button_onclick_js);
 
            Session.Remove("RequestControls");
 
 
 
            if (Session["UserType"].ToString() == "Guest")
            {
                btnBacktoHome.Visible = false;
            }
 
            btnUpdate.OnClientClick = "return Validate('" + hdnError.ClientID + "','" + ddl_Priorities.ClientID + "','" + txtReq_ID.ClientID + "','" + txtSummary.ClientID + "','" + txtProblemDescription.ClientID + "','" + rbAttendStatusYes.ClientID + "','" + rbAttendStatusNo.ClientID + "','" + ddl_Impacts.ClientID + "')";
            btnUpdate2.OnClientClick = "return Validate('" + hdnError.ClientID + "','" + ddl_Priorities.ClientID + "','" + txtReq_ID.ClientID + "','" + txtSummary.ClientID + "','" + txtProblemDescription.ClientID + "','" + rbAttendStatusYes.ClientID + "','" + rbAttendStatusNo.ClientID + "','" + ddl_Impacts.ClientID + "')";
            //btnUpdate.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnUpdate, null) + ";");
 
 
 
            ((ImageButton)DTC_SelectUser.FindControl("btnChoose")).Visible = false;
            ((ImageButton)DTC_SelectUser.FindControl("btnCancel")).Visible = false;
 
 
            if (Request.QueryString["Request_ID"] != null)
            {
                hdnRequest_ID.Value = Request.QueryString["Request_ID"].ToString();
                requests.vClearAttributes();
                requests.Req_ID = hdnRequest_ID.Value;
                requests.vBindRequest();
                vBindControls();
            }
            else
            {
                 
 
                //if (ddl_Priorities.Items.Count > 0)
                //{
                //    if(ddl_Priorities.FindItemByText("Medium").Value!=null)
                //    ddl_Priorities.SelectedValue = ddl_Priorities.FindItemByText("Medium").Value;
                //}
 
            }
             
            
            if (Request.QueryString["Summary"] != null)
            {
                txtSummary.Text = Request.QueryString["Summary"].Replace("$$$", "\r\n");
            }
            if (Request.QueryString["Description"] != null)
            {
                txtProblemDescription.Text = Request.QueryString["Description"].Replace("$$$", "\r\n");
            }
            if (Request.QueryString["AttendStatusYes"] != null)
            {
                General.vHandleRadioButtonValue(rbAttendStatusYes, Request.QueryString["AttendStatusYes"]);
            }
            if (Request.QueryString["AttendStatusNo"] != null)
            {
                General.vHandleRadioButtonValue(rbAttendStatusNo, Request.QueryString["AttendStatusNo"]);
            }
 
        }
        }
        catch (Exception ex)
        {
            general.vShowErrorMessage(Page, ex.Message);
        }
    }
    protected void Page_Prerender(object sender, EventArgs e)
    {      
        try{
            //string scriptString = "<script language=JavaScript>CaptureBackSpace2();</script>";
 
            //if (!this.IsClientScriptBlockRegistered("clientScri pt1"))
            //{
            //    this.RegisterStartupScript("clientScript1", scriptString);
            //}
 
            if (!Page.IsPostBack)
            {
                 
 
                General.vAddDefaultItem(ddl_Impacts);
                General.vAddDefaultItem(ddl_Priorities);
 
                if (Request.QueryString["Request_ID"] == null)
                {
                    ddl_Priorities.Items.Remove(ddl_Priorities.FindItemByText("Immediate"));
                }
                else
                {
                    if (ddl_Priorities.FindItemByText("Immediate") != null)
                        ddl_Priorities.FindItemByText("Immediate").Enabled = false;
                }
 
                if (Request.QueryString["Impact"] != null)
                {
                    General.vHandleSelectedItem(ddl_Impacts, Request.QueryString["Impact"].Trim());
                }
                if (Request.QueryString["Priority_ID"] != null)
                {
                    General.vHandleSelectedValue(ddl_Priorities, Request.QueryString["Priority_ID"]);
                }
            }
        ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value = hdnRequest_ID.Value;
        ((HiddenField)DTC_btn_Attachments.FindControl("hdnScreen_ID")).Value = "1";
        if (hdnRequest_ID.Value == "")
        {
            ((ImageButton)DTC_btn_Attachments.FindControl("btnAttachments")).OnClientClick = "return ShowAttachmentsPopup('" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnScreen_ID")).Value + "','" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value + "')";
        }
        else
        {
            ((ImageButton)DTC_btn_Attachments.FindControl("btnAttachments")).OnClientClick = "return ShowAttachmentsPopup('" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnScreen_ID")).Value + "','" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value + "','true')";
 
        }
        #region SetAttachmentButton
        if (((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value != "")
        {
            screen_Files.vClearScreen_Files();
 
            screen_Files.Screen_ID = ((HiddenField)DTC_btn_Attachments.FindControl("hdnScreen_ID")).Value;
            screen_Files.Record_ID = ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value;
 
 
            DataTable dt = screen_Files.dtGetScreen_Files();
            if (dt.Rows.Count > 0)
            {
                ((Label)DTC_btn_Attachments.FindControl("lblDocs")).Text = "" + dt.Rows.Count + " attached files";//((ImageButton)DTC_btn_Attachments.FindControl("btnAttachments")).ToolTip = "You Have Attached Files";
            }
        }
        #endregion
        }
        catch (Exception ex)
        {
            general.vShowErrorMessage(Page, ex.Message);
        }
    }
    protected void btnUpdate_Click(object sender, ImageClickEventArgs e)
    {
        try{
            if (ddl_Impacts.SelectedValue == "" || ddl_Priorities.SelectedValue == "" || txtSummary.Text.Trim() == "" || txtProblemDescription.Text.Trim() == "")
            {
                general.vShowMessage(Page, "Un sufficient entered information, Please fill all mandatory fields.");
                return;
            }
            System.Threading.Thread.Sleep(1500);
             
            if (hdnRequest_ID.Value != "")
            {
                requests = new Requests();
                requests.Req_ID = hdnRequest_ID.Value;
                requests.vBindRequest();
                vBindControls();
            }
 
        requests.Req_ID = hdnRequest_ID.Value;
        //requests.Req_ID2 = txtReq_ID.Text;
        requests.Summary = txtSummary.Text.Trim();
 
        requests.Intiator_ID = Session["User_ID"].ToString();// txtInitiator_ID.Value;
        requests.RequestType_ID = ddl_RequestTypes.SelectedValue;
 
        requests.Summary = txtSummary.Text.Trim();
        requests.ProblemDescription = txtProblemDescription.Text.Trim();
        requests.Priority_ID = ddl_Priorities.SelectedValue;
        requests.Impact_ID = ddl_Impacts.SelectedValue;
        if(rbAttendStatusYes.Checked || rbAttendStatusNo.Checked)
        requests.AttendStatus = rbAttendStatusYes.Checked ? "true" : "false";
 
        requests.Requester_ID = Session["User_ID"].ToString();// txtRequester_ID.Value;
        requests.Status_ID = "4";
        requests.Mode_ID = "1";
 
        if (hdnRequest_ID.Value == "")
        {
            requests.dtInsUpRequests();
            hdnRequest_ID.Value = requests.Req_ID;
            #region Attachments
            if (Request.QueryString["Request_ID"] == null)
            {
                screen_Files.nUpdateRecord_ID(((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value, hdnRequest_ID.Value);
                //screen_Files.vInsertAttachments(DTC_btn_Attachments, requests.Req_ID, "1", Page);
                if (screen_Files.error != "")
                {
                    general.vShowErrorMessage(Page, screen_Files.error);
                }
            }
            #endregion
            if (hdnRequest_ID.Value != "")
            {
 
                if (Request.QueryString["Request_ID"] == null)
                {
                    btnUpdate.Visible = false;
                    btnUpdate2.Visible = false;
                    if (requests.Status_ID == "5")
                        requests.vNotifyAdminForOnHoldRequests();
                    else
                        requests.vNotifyAdminWhenNewRequestSubmitted();
                    requests.vNotifyUserWhenRequestIsSubmitted();
                }
                btnAdvance.Style["display"] = "none";
                btnAdvance0.Style["display"] = "none";
                txtProblemDescription.Enabled = false;
                txtSummary.Enabled = false;
                rbAttendStatusNo.Enabled = false;
                rbAttendStatusYes.Enabled = false;
                ddl_Impacts.Enabled = false;
                ddl_Priorities.Enabled = false;
                ddl_RequestTypes.Enabled = false;
                ((ImageButton)DTC_btn_Attachments.FindControl("btnAttachments")).Visible = true;
                btnUpdate.Enabled = false;
                general.vShowSuccessMessage(Page, ", Request ID is " + requests.Req_ID2);
                Response.Redirect(@"..\UserHomePage\DTC_UserHomePage3.aspx?Tab=Requests");
                //general.vShowSuccessMessage(Page);               
            }
            else
            {
                btnUpdate.Style["visibility"] = "visibile";
                general.vShowErrorMessage(Page, requests.error);
            }
        }
        else
        {
            if (requests.nInsUpRequests() > 0)
            {
                general.vShowSuccessMessage(Page);
            }
            else
            {
                btnUpdate.Style["visibility"] = "visibile";
                general.vShowErrorMessage(Page, requests.error);
            }
        }
        }
        catch (Exception ex)
        {
            btnUpdate.Style["visibility"] = "visibile";
            general.vShowErrorMessage(Page, ex.Message);
        }
    }
    void vBindControls()
    {
        try{
        hdnRequest_ID.Value = requests.Req_ID;
        txtReq_ID.Text = requests.Req_ID2;
 
        txtSummary.Text = requests.Summary;
        txtProblemDescription.Text = requests.ProblemDescription;
        ddl_Priorities.SelectedValue = requests.Priority_ID;
        ddl_Impacts.SelectedValue = requests.Impact_ID;
        rbAttendStatusNo.Checked = requests.AttendStatus == "true" ? true : false;
 
        //users.vBindUserNameControls(requests.Intiator_ID, txtInitiator_ID, txtInitiatorName, txtInitiator_ID2);
        //users.vBindUserNameControls(requests.Requester_ID, txtRequester_ID, txtRequesterName, txtRequester_ID2);
 
         
        ddl_RequestTypes.SelectedValue = requests.RequestType_ID;
        txtSummary.Text = requests.Summary;
        }
        catch (Exception ex)
        {
            general.vShowErrorMessage(Page, ex.Message);
        }
    }
 
    protected void btnCancel_Click(object sender, ImageClickEventArgs e)
    {
        try{
        if (Request.Url.AbsoluteUri.IndexOf("Guest") == -1)
            Response.Redirect("../UserHomePage/DTC_UserHomePage3.aspx?Tab=Requests");           
        else
            Response.Redirect("../Login/DTC_Login.aspx");
        }
        catch (Exception ex)
        {
            general.vShowErrorMessage(Page, ex.Message);
        }
 
    }
    protected void btnAdvance_Click(object sender, EventArgs e)
    {
        try{
 
        if (hdnRequest_ID.Value != "")
        {
            if (Request.Url.AbsoluteUri.IndexOf("Guest") == -1)
            Response.Redirect("DTC_Request_Advanced.aspx?Request_ID=" + hdnRequest_ID.Value);
            else
            Response.Redirect("DTC_Request_Advanced_Guest.aspx?Request_ID=" + hdnRequest_ID.Value);
 
        }
        else
        {
            Session["RequestControls"] = "yes";
            if (Request.Url.AbsoluteUri.IndexOf("Guest") == -1)
                Response.Redirect("DTC_Request_Advanced.aspx?PreviousPage=DTC_Request.aspx&Priority_ID=" + ddl_Priorities.SelectedValue + "&Impact=" + ddl_Impacts.SelectedItem.Text + "&Summary=" + txtSummary.Text.Trim().Replace("\r\n", "$$$") + "&Description=" + txtProblemDescription.Text.Trim().Replace("\r\n", "$$$") + "&AttendStatusYes=" + rbAttendStatusYes.Checked + "&AttendStatusNo=" + rbAttendStatusNo.Checked + "&TempRecord_ID=" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value);
 
            //Response.Redirect("DTC_Request_Advanced.aspx");
            else
                Response.Redirect("DTC_Request_Advanced_Guest.aspx?PreviousPage=DTC_Request.aspx&Priority_ID=" + ddl_Priorities.SelectedValue + "&Impact=" + ddl_Impacts.SelectedItem.Text + "&Summary=" + txtSummary.Text.Trim().Replace("\r\n", "$$$") + "&Description=" + txtProblemDescription.Text.Trim().Replace("\r\n", "$$$") + "&AttendStatusYes=" + rbAttendStatusYes.Checked + "&AttendStatusNo=" + rbAttendStatusNo.Checked + "&TempRecord_ID=" + ((HiddenField)DTC_btn_Attachments.FindControl("hdnRecord_ID")).Value);
        }
 
        //Server.Transfer("DTC_Request_Advanced.aspx?Request_ID=" + hdnRequest_ID.Value + "&PreviousPage=" + Request.QueryString["PreviousPage"] != "" ? Request.QueryString["PreviousPage"].ToString() : "");
        }
        catch (Exception ex)
        {
            general.vShowErrorMessage(Page, ex.Message);
        }
 
    }
 
    protected void btnBack_Click(object sender, EventArgs e)
    {
         
    }
    protected void btnBacktoHome_Click(object sender, EventArgs e)
    {
        if (Request.Url.ToString().IndexOf("User") != -1)
        {
            Response.Redirect(@"..\UserHomePage\DTC_UserHomePage3.aspx?Tab=Requests");
        }
         
    }
}
and here is user control popups the atachments page

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DTC_btn_Attachments.ascx.cs" Inherits="UI_UserControls_DTC_btn_Attachments" %>
<%@ Register assembly="RadCalendar.Net2" namespace="Telerik.WebControls" tagprefix="radU" %>
<%@ Register Assembly="RadUpload.Net2" Namespace="Telerik.WebControls" TagPrefix="radU" %>
 
 
 
<script type="text/javascript">
 
    function ShowAttachmentsPopup(Screen_ID, Record_ID/*hdnSelectedFilesClient_ID*/) {
//        debugger
//        if (Record_ID == "NA" || Record_ID =="")
//            return true;
        try {
            Screen_ID = document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnScreen_ID').value;
            Record_ID = document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnRecord_ID').value;
        }
        catch (e) {
            Screen_ID = document.getElementById('DTC_btn_Attachments_hdnScreen_ID').value;
            Record_ID = document.getElementById('DTC_btn_Attachments_hdnRecord_ID').value;
       }
       if (Record_ID == "") {
           Record_ID = "NA";
       }
       window.open("../DTC_Attachments.aspx?Screen_ID=" + Screen_ID + "&Record_ID=" + Record_ID, "mywindow", "top=0,left=0,width=1024,height=768,directories=false,location=false,menubar=no,resizable=false,scrollbars=yes,status=no,toolbar=no,fullscreen=true");
//       window.showModalDialog("../DTC_Attachments.aspx?Screen_ID=" + Screen_ID + "&Record_ID=" + Record_ID, window, "dialogWidth:900px;dialogHeight:480px;scroll:yes;resizable:yes;status:no;help:no;");
        
        return false;
    }
    function ShowAttachmentsPopup(Screen_ID, Record_ID,ReadOnly) {
//               debugger
//        if (Record_ID == "NA" || Record_ID == "")
//            return true;
        try {
            Screen_ID = document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnScreen_ID').value;
            Record_ID = document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnRecord_ID').value;
        }
        catch (e) {
            Screen_ID = document.getElementById('DTC_btn_Attachments_hdnScreen_ID').value;
            Record_ID = document.getElementById('DTC_btn_Attachments_hdnRecord_ID').value;
        }
        if (Record_ID == "") {
            Record_ID = "NA";
        }
        window.open("../DTC_Attachments.aspx?Screen_ID=" + Screen_ID + "&Record_ID=" + Record_ID + "&ReadOnly=" + ReadOnly, "mywindow", "top=0,left=0,width=1024,height=768,directories=false,location=false,menubar=no,resizable=false,scrollbars=yes,status=no,toolbar=no,fullscreen=true");
//        window.showModalDialog("../DTC_Attachments.aspx?Screen_ID=" + Screen_ID + "&Record_ID=" + Record_ID + "&ReadOnly=" + ReadOnly, window, "dialogWidth:900px;dialogHeight:480px;scroll:yes;resizable:yes;status:no;help:no;");
         
        return false;
    }
//    function SaveFile1() {
//    debugger
//        if (document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_File1') != null) {
//            document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnFile1').value = document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_File1').value;
 
//            alert(document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_File1').value);
//            alert(document.getElementById('ctl00_ContentPlaceHoder1_DTC_btn_Attachments_hdnFile1').value);
//           
//        }
//        return false;
//    }
</script>
<asp:HiddenField ID="hdnSelectedFiles" runat="server" />
 
 
 
 
<asp:HiddenField ID="hdnScreen_ID" runat="server" />
 
 
<asp:HiddenField ID="hdnRecord_ID" Value='<%# Bind("Record_ID") %>' 
    runat="server" />
 
 
 
 
 
 
 
<%--<asp:HiddenField ID="hdnFile1" runat="server" />
 
 
 
 
<asp:HiddenField ID="hdnFile2" runat="server" />
 
 
 
 
<asp:HiddenField ID="hdnFile3" runat="server" />
 
 
 
 
<asp:HiddenField ID="hdnFile4" runat="server" />
 
 
 
 
<asp:HiddenField ID="hdnFile5" runat="server" />--%>
 
 
 
 
 
 
 
               <table border="0" cellpadding="0" cellspacing="0">
                   <tr>
                       <td valign="bottom">
                           <table  border="0" cellpadding="0" cellspacing="0">
                               <tr>
                                   <td >
                                       <asp:Label ID="lblDocs" CssClass="ContentText" runat="server" Text=""></asp:Label>
                                       </td>
                                   <td>
                           <asp:ImageButton ID="btnAttachments" runat="server" ImageUrl="~/UI/images/attachments.jpg"
    OnClick="btnAttachments_Click" />
 
                            
                                   </td>
                               </tr>
                           </table>
 
                            
                           </td>
                   </tr>
                   <tr>
                       <td>
                 <input id="File1" runat="server" name="File1" type="file" maxlength="2000"
                               visible="False" /></td>
                   </tr>
                   <tr>
                       <td>
                 <input id="File2" runat="server" name="File2" type="file" maxlength="2000"
                               visible="False" /></td>
                   </tr>
                   <tr>
                       <td>
                 <input id="File3" runat="server" name="File3" type="file" maxlength="2000"
                               visible="False" /></td>
                   </tr>
                   <tr>
                       <td>
                 <input id="File4" runat="server" name="File4" type="file" maxlength="2000"
                               visible="False" /></td>
                   </tr>
                   <tr>
                       <td>
                 <input id="File5" runat="server" name="File5" type="file" maxlength="2000"
                               visible="False" /></td>
                   </tr>
</table>
 
                
                

0
Kiara
Top achievements
Rank 1
answered on 05 Aug 2010, 12:23 PM
Your code is quite complex and if you do not isolate a test case which reproduces the issue, it would be very hard to pinpoint the cause of it. Spend some time to debug and strip a subset of your app and then post the code either here or in a support ticket to get some help from the Telerik folks.
Tags
General Discussions
Asked by
Ihab
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Ihab
Top achievements
Rank 1
Share this question
or