FindControl() публичный Метод

public FindControl ( string id ) : Control
id string
Результат Control
        private static void ComputerMove()
        {
            Random rand = new Random();
            int positionIndex = rand.Next(0, freePositions.Count);
            Position position = freePositions[positionIndex];
            int row = position.X;
            int col = position.Y;

            if (game[row, col] == '*')
            {
                game[row, col] = computerCharacter;
                freePositions.Remove(position);
                Button btn = new Button();
                Page page = new Page();
                if (HttpContext.Current != null)
                {
                    page = (Page)HttpContext.Current.Handler;
                    btn = (Button)page.FindControl("Btn" + row + col);
                    btn.Text = computerCharacter.ToString();
                }
                if (Win(computerCharacter))
                {
                    Label lbWinner = (Label)page.FindControl("Winner");
                    lbWinner.Text = "You win!";
                    lbWinner.Visible = true;
                    computerScores++;
                    UpdateScores(page);
                    return;
                }
            }
            else
            {
                ComputerMove();
            }
        }
Пример #2
0
		public static void RenderLabelTest (Page p)
		{
			Assert.AreEqual (Color.Black,((MyWebControl.Label) p.FindControl ("Label")).BackColor, "Default Theme#1");
			Assert.AreEqual (Color.Red, ((MyWebControl.Label) p.FindControl ("LabelRed")).BackColor, "Red Skin Theme#2");
			Assert.AreEqual (Color.Yellow, ((MyWebControl.Label) p.FindControl ("LabelYellow")).BackColor, "Yellow Skin Theme#3");
			Assert.AreEqual (Color.Black, ((MyWebControl.Label) p.FindControl ("LabelOverride")).BackColor, "Override Skin Theme#4");
		}
        /// <summary>
        /// 儲存TestDuration的設定
        /// </summary>
        public void saveTestDurationPresentation(System.Web.UI.Page WebPage, string strPaperID)
        {
            RadioButton rbYes = ((RadioButton)(WebPage.FindControl("Form1").FindControl("rb-Duration-Yes")));

            //TestDuration的時間
            int intDuration = 0;

            DropDownList dlDuration = new DropDownList();

            if (rbYes.Checked)
            {
                //取得時間
                dlDuration = ((DropDownList)(WebPage.FindControl("Form1").FindControl("dlTestDuration")));

                intDuration = Convert.ToInt32(dlDuration.SelectedItem.Value);
            }
            else
            {
                intDuration = 0;
            }

            //			if(intDuration > 0)
            //			{
            //				dlDuration.Attributes["disabled"] = "";
            //			}
            //			else
            //			{
            //				dlDuration.Attributes["disabled"] = "disabled";
            //			}

            SqlDB  myDB   = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            string strSQL = "UPDATE Paper_Header SET sTestDuration = '" + intDuration.ToString() + "' WHERE cPaperID = '" + strPaperID + "' ";

            myDB.ExecuteNonQuery(strSQL);
        }
        /// <summary>
        /// Gets the ID of the post back control.
        ///
        /// See: http://geekswithblogs.net/mahesh/archive/2006/06/27/83264.aspx
        /// </summary>
        /// <param name = "page">The page.</param>
        /// <returns></returns>
        private static string GetPostBackControlClientId(HttpContext context, Page page, NameValueCollection requestForm)
        {
            if (page == null || !page.IsPostBack)
            {
                return(string.Empty);
            }

            Control control = null;
            // first we will check the "__EVENTTARGET" because if post back made by the controls
            // which used "_doPostBack" function also available in Request.Form collection.
            var requestParams = requestForm != null?WebHelper.ParamsWithSpecialRequestForm(context, requestForm) : context.Request?.Params;

            string controlName = requestParams["__EVENTTARGET"];

            if (!String.IsNullOrEmpty(controlName))
            {
                control = page.FindControl(controlName);
            }
            else
            {
                // if __EVENTTARGET is null, the control is a button type and we need to
                // iterate over the form collection to find it

                // ReSharper disable TooWideLocalVariableScope
                string  controlId;
                Control foundControl;
                // ReSharper restore TooWideLocalVariableScope

                foreach (string ctl in context.Request.Form)
                {
                    // handle ImageButton they having an additional "quasi-property"
                    // in their Id which identifies mouse x and y coordinates
                    if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                    {
                        controlId    = ctl.Substring(0, ctl.Length - 2);
                        foundControl = page.FindControl(controlId);
                    }
                    else
                    {
                        foundControl = page.FindControl(ctl);
                    }

                    if (!(foundControl is IButtonControl))
                    {
                        continue;
                    }

                    control = foundControl;
                    break;
                }
            }

            return(control == null ? String.Empty : control.ClientID);
        }
Пример #5
0
 public static Control FindPagesControlByID(string cid,Page page)
 {
     if (page.Master == null)
         return page.FindControl(cid);
     else
         return page.Master.FindControl(cid);
 }
Пример #6
0
        /// <summary>
        /// Render CSS path.
        /// </summary>
        /// <param name="page">Page instance</param>
        /// <param name="name">name</param>
        /// <param name="cssFilePath">FilePath</param>
        /// <param name="OverwriteExisting">Overwrite existing path if exists.</param>
        public static void RenderCSSPath(Page page, string name, string cssFilePath, bool OverwriteExisting)
        {
            if (page == null || page.Header == null)
                return;

            if (cssFilePath == null)
                cssFilePath = string.Empty;
            HtmlLink link = (HtmlLink)page.FindControl(name);
            //foreach (Control control in page.Header.Controls)
            //    if (control is HtmlLink)
            //    {
            //        HtmlLink link = (HtmlLink)control; 
            if (link != null)
            {
                if (link.ID.ToLower().Equals(name.ToLower()) && !string.IsNullOrEmpty(cssFilePath))
                {
                    if (OverwriteExisting)
                        link.Href = cssFilePath;
                    else
                    {
                        if (String.IsNullOrEmpty(link.Href))
                            link.Href = cssFilePath;
                    }
                    //    }
                }
            }
        }
 /// <summary>
 /// Find The HTML Element Inside The HTML Controls, Inside The User Control, Inside The Page And Change The Css Property Of It.
 /// </summary>
 /// <param name="page">Page</param>
 /// <param name="userControlID">UserControlID</param>
 /// <param name="htmlControlID">HTML ControlID</param>
 /// <param name="elementID">Element ID</param>
 /// <param name="key"> Css Tag</param>
 /// <param name="value">Value</param>
 public void ChangeCss(Page page, string userControlID, string htmlControlID, string elementID, string key, string value)
 {
     PlaceHolder pchWhole = page.FindControl(userControlID) as PlaceHolder;
     UserControl uc = pchWhole.FindControl(htmlControlID) as UserControl;
     HtmlGenericControl div = uc.FindControl(elementID) as HtmlGenericControl;
     div.Attributes.Add(key, value);
 }
Пример #8
0
    public static void mostrarAlerta(string mensaje, System.Web.UI.Page pagina, tipoAlerta tipoAlerta = tipoAlerta.info, Boolean tieneMasterPage = true)
    {
        StringBuilder      html             = new StringBuilder();
        LiteralControl     control          = new LiteralControl();
        HtmlGenericControl divNotifications = new HtmlGenericControl();

        try
        {
            html.Append(" <div class='alert alert-" + tipoAlerta.ToString() + " alert-dismissible' role='alert'>");
            html.Append("<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times</span></button>");
            html.Append(mensaje);
            html.Append("</div>");

            control.Text = html.ToString();
            if (tieneMasterPage)
            {
                divNotifications = pagina.Master.FindControl("divNotifications") as HtmlGenericControl;
            }
            else
            {
                divNotifications = pagina.FindControl("divNotifications") as HtmlGenericControl;
            }
            divNotifications.Controls.Add(control);
        }
        catch (Exception ex)
        {
            escribeError(ex.Message, "clsHelper.cs", ex.StackTrace);
        }
    }
Пример #9
0
        private static void AddIncludeToPage(System.Web.UI.Page page, string url, NameValueCollection nvc, string receivingControlId = "pResources", IncludeType includeType = IncludeType.Script)
        {
            if (page == null || String.IsNullOrEmpty(url) || nvc == null || String.IsNullOrEmpty(receivingControlId))
            {
                return;
            }

            var attributeBuilder = new StringBuilder();

            foreach (var key in nvc.AllKeys)
            {
                attributeBuilder.AppendFormat(" {0}={1}", key, nvc[key]);
            }

            Control pResources = page.FindControl(receivingControlId);

            if (pResources != null)
            {
                Literal litInclude = new Literal();

                if (includeType == IncludeType.Script)
                {
                    litInclude.Text = "<script src='" + url + "' " + attributeBuilder.ToString() + " type='text/javascript'></script>";
                }
                else
                {
                    litInclude.Text = "<link href='" + url + "' " + attributeBuilder.ToString() + " rel='stylesheet' type='text/css' />";
                }

                pResources.Controls.Add(litInclude);
            }
        }
Пример #10
0
        protected Control GetPostBackControl(System.Web.UI.Page page)
        {
            Control control  = null;
            string  ctrlname = Page.Request.Params["__EVENTTARGET"];

            if (ctrlname != null && ctrlname != String.Empty && !ctrlname.Contains("lbLogout") && ctrlname.Split('$').Length > 1)
            {
                //crtlname must contain the id of the control inside my usercontrol that caused the postback
                if (ctrlname.Contains("SaveMilestone"))
                {
                    var c = new Control();
                    c.ID = ctrlname;
                    return(c);
                }
                else
                {
                    if (ctrlname.Split('$').Length > 2)
                    {
                        control = FindControlRecursive(page, ctrlname.Split('$')[2]);
                    }
                }
            }
            else
            {
                string  ctrlStr = String.Empty;
                Control c       = null;
                foreach (string ctl in Page.Request.Form)
                {
                    if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                    {
                        ctrlStr = ctl.Substring(0, ctl.Length - 2);
                        c       = page.FindControl(ctrlStr);
                    }
                    else
                    {
                        c = page.FindControl(ctl);
                    }
                    if (c is System.Web.UI.WebControls.CheckBox ||
                        c is System.Web.UI.WebControls.CheckBoxList)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return(control);
        }
Пример #11
0
        public void Load_ControlEditor_TemplateDesignMode(System.Web.UI.Page myPage, string Page_ControlID)
        {
            Templates.MasterPageEditorMgr myMasterPageEditor   = new Templates.MasterPageEditorMgr();
            MasterPage_Lock_Control       myMasterPage_Control = myMasterPageEditor.Get_MasterPage_Lock_Control(Page_ControlID);

            Modules.ModuleMgr         myModuleMgr = new Modules.ModuleMgr();
            Modules.Component         myComponent = myModuleMgr.Get_Component(myMasterPage_Control.ComponentID);
            Modules.Component_Control myControl   = myModuleMgr.Get_Control(myMasterPage_Control.ComponentID, Modules.Control_Type.Editor);

            if (myControl.Assembly_Name != null)
            {
                Assembly assembly = Assembly.Load(new AssemblyName(myControl.Assembly_Name));

                Type    _control_type = assembly.GetType(myControl.Class_Name);
                Control _control      = myPage.LoadControl(_control_type, null);

                List <MasterPage_Lock_Control_Property> Control_Properties = myMasterPageEditor.Get_MasterPage_Lock_Control_Properties(myMasterPage_Control.Page_ControlID);

                // Load Exist Control
                foreach (MasterPage_Lock_Control_Property Control_Property in Control_Properties)
                {
                    PropertyInfo _Control_Property = _control_type.GetProperty(Control_Property.Property_Name);

                    switch (_Control_Property.PropertyType.FullName)
                    {
                    case "System.String":
                        _Control_Property.SetValue(_control, Control_Property.Property_Value, null);
                        break;

                    case "System.Int32":
                        _Control_Property.SetValue(_control, Convert.ToInt32(Control_Property.Property_Value), null);
                        break;

                    case "System.Boolean":
                        _Control_Property.SetValue(_control, Convert.ToBoolean(Control_Property.Property_Value), null);
                        break;

                    default:
                        _Control_Property.SetValue(_control, Control_Property.Property_Value, null);
                        break;
                    }
                }

                // Place PageControlID and EditMode
                PropertyInfo Page_ControlID_Property = _control_type.GetProperty("Page_ControlID");
                Page_ControlID_Property.SetValue(_control, Page_ControlID, null);

                PropertyInfo EditMode_Property = _control_type.GetProperty("EditMode");
                EditMode_Property.SetValue(_control, "TemplateDesignMode", null);

                // Create Editor
                PlaceHolder myPlaceHolder = (PlaceHolder)myPage.FindControl("PlaceHolder_Editor");
                myPlaceHolder.Controls.Add(_control);
            }
            else
            {
                throw new Exception(string.Format("Invalid PageControl Editor.Design Mode ComponentID: {0}", myMasterPage_Control.ComponentID));
            }
        }
 public void RegisterAjaxAntiForgery(Page page)
 {
     var ctl = page.FindControl("ClientResourcesFormBottom");
     if(ctl != null)
     {
         ctl.Controls.Add(new LiteralControl(AntiForgery.GetHtml().ToHtmlString()));
     }
 }
Пример #13
0
 /// <summary>
 /// Get the script manager that is contained within the current page.
 /// </summary>
 /// <param name="scriptManagerID">The script manager to find in the current page.</param>
 /// <param name="page">The page that contains the script manager.</param>
 /// <returns>The script manager reference else null.</returns>
 public static System.Web.UI.ScriptManager GetScriptManager(String scriptManagerID, System.Web.UI.Page page)
 {
     try
     {
         // Try find the script manager on the page.
         return((System.Web.UI.ScriptManager)page.FindControl(scriptManagerID));
     }
     catch { return(null); }
 }
Пример #14
0
        protected Control GetPostBackControl(System.Web.UI.Page page)
        {
            Control control  = null;
            string  ctrlname = Page.Request.Params["__EVENTTARGET"];

            if (ctrlname != null && ctrlname != String.Empty)
            {
                if (ctrlname.Split('$')[2].Contains("options") || ctrlname.Split('$')[2].Contains("orConditions"))
                {
                    var c = new Control();
                    c.ID = ctrlname;
                    return(c);
                }
                else
                {
                    control = FindControlRecursive(page, ctrlname.Split('$')[2]);
                }
            }
            else
            {
                string  ctrlStr = String.Empty;
                Control c       = null;
                foreach (string ctl in Page.Request.Form)
                {
                    if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                    {
                        ctrlStr = ctl.Substring(0, ctl.Length - 2);
                        c       = page.FindControl(ctrlStr);
                    }
                    else
                    {
                        c = page.FindControl(ctl);
                    }
                    if (c is System.Web.UI.WebControls.CheckBox ||
                        c is System.Web.UI.WebControls.CheckBoxList)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return(control);
        }
Пример #15
0
 public void RegisterAjaxAntiForgery(Page page)
 {
     var helper = CreateHtmlHelper();
     var field = helper.AntiForgeryToken();
     var ctl = page.FindControl("ClientResourcesFormBottom");
     if(ctl != null)
     {
         ctl.Controls.Add(new LiteralControl(field.ToHtmlString()));
     }
 }
Пример #16
0
 public static Control GetPostBackControl(Page page)
 {
     string evTarget = page.Request.Params["__EVENTTARGET"];
     if (!string.IsNullOrEmpty(evTarget))
     {
         return page.FindControl(evTarget);
     }
     else
     {
         foreach (string nCtrl in page.Request.Form)
         {
             Control ctrl = page.FindControl(nCtrl);
             if (ctrl is Button)
             {
                 return ctrl;
             }
         }
         return null;
     }
 }
        /// <summary>
        /// 儲存PresentMethod的設定
        /// </summary>
        /// <param name="WebPage"></param>
        /// <param name="strPaperID"></param>
        public void savePresentPresentation(System.Web.UI.Page WebPage, string strPaperID, string strCaseID, int intClinicNum, string strSectionName)
        {
            DropDownList dlPresent = ((DropDownList)(WebPage.FindControl("Form1").FindControl("dlPresent")));

            string strSelectWorkType = dlPresent.SelectedItem.Value;

            SqlDB  myDB   = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            string strSQL = "UPDATE UserLevelPresent SET sWorkType = '" + strSelectWorkType + "' WHERE cCaseID = '" + strCaseID + "' AND sClinicNum = '" + intClinicNum.ToString() + "' AND cSectionName = '" + strSectionName + "' ";

            myDB.ExecuteNonQuery(strSQL);
        }
Пример #18
0
        public static Control GetControlThatCausedPostBack(Page page)
        {
            //initialize a control and set it to null
            Control ctrl = null;

            //get the event target name and find the control
            string ctrlName = page.Request.Params.Get("__EVENTTARGET");
            if (!String.IsNullOrEmpty(ctrlName))
                ctrl = page.FindControl(ctrlName);

            //return the control to the calling method
            return ctrl;
        }
Пример #19
0
		public static void SetPageTitle(Page page, string sTitle)
		{
			try
			{
				Literal litPageTitle = page.FindControl("litPageTitle") as Literal;
				if ( litPageTitle != null )
					litPageTitle.Text = sTitle;
			}
			catch(Exception ex)
			{
				SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
			}
		}
        protected Control GetPostBackControl(System.Web.UI.Page page)
        {
            Control control = null;

            try
            {
                string ctrlName = page.Request.Params.Get("__EVENTTARGET");

                if (ctrlName != null && ctrlName != String.Empty)
                {
                    control = page.FindControl(ctrlName);
                }
                else
                {
                    ContentPlaceHolder cph =
                        (ContentPlaceHolder)page.FindControl("cpMainContent");
                    for (int i = 0, len = page.Request.Form.Count; i < len; i++)
                    {
                        string[] ctl = page.Request.Form.AllKeys[i].Split('$');
                        if (ctl.Length > 2)
                        {
                            control = cph.FindControl(ctl[2])
                                      as System.Web.UI.WebControls.Button;
                        }

                        if (control != null)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(control);
        }
        public static Control GetPostBackControl(Page page)
        {
            Control control = null;

            string ctrlname = page.Request.Params.Get("__EVENTTARGET");
            if (ctrlname != null && ctrlname != string.Empty)
            {
                control = page.FindControl(ctrlname);
            }
            else
            {
                foreach (string ctl in page.Request.Form)
                {
                    Control c = page.FindControl(ctl);
                    if (c is System.Web.UI.WebControls.Button)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return control;
        }
Пример #22
0
    public System.Web.UI.Control GetPostBackControl(System.Web.UI.Page page)
    {
        Control control  = null;
        string  ctrlname = page.Request.Params["__EVENTTARGET"];

        if (ctrlname != null && ctrlname != String.Empty)
        {
            control = page.FindControl(ctrlname);
        }
        // if __EVENTTARGET is null, the control is a button type and we need to
        // iterate over the form collection to find it
        else
        {
            string  ctrlStr = String.Empty;
            Control c       = null;
            foreach (string ctl in page.Request.Form)
            {
                // handle ImageButton controls ...
                if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                {
                    ctrlStr = ctl.Substring(0, ctl.Length - 2);
                    c       = page.FindControl(ctrlStr);
                }
                else
                {
                    c = page.FindControl(ctl);
                }
                if (c is System.Web.UI.WebControls.Button ||
                    c is System.Web.UI.WebControls.ImageButton)
                {
                    control = c;
                    break;
                }
            }
        }
        return(control);
    }
Пример #23
0
 public void BindControl(object t, Page page)
 {
     foreach (PropertyInfo pi in t.GetType().GetProperties())
     {
         if (pi.CanRead)
         {
             Control ctrl = page.FindControl(pi.Name);
             if (ctrl != null)
             {
                 object value = core.GetPropertyValue(t, pi);
                 SetControl(ctrl, value);
             }
         }
     }
 }
Пример #24
0
        public static Control GetPostBackControl(System.Web.UI.Page page)
        {
            Control control = null;

            string ctrlname = page.Request.Params.Get("__EVENTTARGET");

            if (!string.IsNullOrEmpty(ctrlname))
            {
                control = page.FindControl(ctrlname);
            }
            else
            {
                foreach (string ctl in page.Request.Form)
                {
                    Control c = page.FindControl(ctl.Replace(".x", ""));
                    if (c is ImageButton)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return(control);
        }
Пример #25
0
        public static Control GetPostBackControl(System.Web.UI.Page page)
        {
            Control control = null;

            string ctrlname = page.Request.Params.Get("__EVENTTARGET");

            if (ctrlname != null && ctrlname != string.Empty)
            {
                control = page.FindControl(ctrlname);
            }
            else
            {
                foreach (string ctl in page.Request.Form)
                {
                    Control c = page.FindControl(ctl);
                    if (c is System.Web.UI.WebControls.Button)
                    {
                        control = c;
                        break;
                    }
                }
            }
            return(control);
        }
Пример #26
0
 /// <summary>
 /// 准备控件。Ajax。
 /// </summary>
 /// <param name="page">WEB窗体引用。</param>
 /// <param name="showLink">是否显示链接。null表示使用默认值。</param>
 public static void Prepare(Page page, bool? showLink)
 {
     object ctl = null;
     if (page.Master != null)
         ctl = page.Master.FindControl("PWMessage");
     if (ctl == null)
         ctl = page.FindControl("PWMessage");
     if (ctl != null)
     {
         ((PopupWin)ctl).Visible = true;
         if (showLink.HasValue)
         {
             ((PopupWin)ctl).ShowLink = showLink.Value;
         }
     }
 }
Пример #27
0
        /// <summary>
        ///     将实体类填充到控件中
        /// </summary>
        /// <param name="page">当前页</param>
        /// <param name="info">要填入数据的实体类</param>
        /// <param name="contentPlaceHolderID">母版页面版ID</param>
        /// <param name="prefix">控件前缀</param>
        public static void Fill <TEntity>(this TEntity info, System.Web.UI.Page page, string contentPlaceHolderID, string prefix = "hl") where TEntity : class
        {
            if (info == null)
            {
                return;
            }

            var masterControl = page.FindControl(contentPlaceHolderID);

            if (masterControl == null)
            {
                return;
            }

            Fill(masterControl.Controls, info, prefix);
        }
        /// <summary>
        /// Moves the selected item to list box.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="control">The control id.</param>
        public void MoveSelectedToListBox(System.Web.UI.Page page, string control)
        {
            // Get left listbox
            OrderedListBox listbox = (OrderedListBox)page.FindControl(control);

            int index = 0;

            for (index = _items.Count - 1; index >= 0; index--)
            {
                OrderedListBoxItem item = (OrderedListBoxItem)_items[index];

                if (item.Selected && !item.Locked)
                {
                    listbox.Items.Add(item);
                    _items.RemoveAt(index);
                }
            }
        }
Пример #29
0
        public void Load_ControlPanel(System.Web.UI.Page myPage, string PlaceHolder_ID, string ControlID, e2Data[] MyProperties)
        {
            Modules.ModuleMgr myModuleMgr = new Modules.ModuleMgr();

            Modules.Component_Control myControl = myModuleMgr.Get_Control(ControlID);

            if (myControl.Assembly_Name != null)
            {
                Assembly assembly = Assembly.Load(new AssemblyName(myControl.Assembly_Name));

                Type    _control_type = assembly.GetType(myControl.Class_Name);
                Control _control      = myPage.LoadControl(_control_type, null);

                // Load Exist Control
                foreach (e2Data myProperty in MyProperties)
                {
                    PropertyInfo _Control_Property = _control_type.GetProperty(myProperty.FieldName);

                    switch (_Control_Property.PropertyType.FullName)
                    {
                    case "System.String":
                        _Control_Property.SetValue(_control, myProperty.FieldValue, null);
                        break;

                    case "System.Int32":
                        _Control_Property.SetValue(_control, Convert.ToInt32(myProperty.FieldValue), null);
                        break;

                    case "System.Boolean":
                        _Control_Property.SetValue(_control, Convert.ToBoolean(myProperty.FieldValue), null);
                        break;

                    default:
                        _Control_Property.SetValue(_control, myProperty.FieldValue, null);
                        break;
                    }
                }

                // Create Control
                PlaceHolder myPlaceHolder = (PlaceHolder)myPage.FindControl(PlaceHolder_ID);
                myPlaceHolder.Controls.Add(_control);
            }
        }
Пример #30
0
        protected void Application_Error(object sender, EventArgs e)
        {
            HttpContext ctx       = HttpContext.Current;
            String      appPath   = ctx.Request.AppRelativeCurrentExecutionFilePath;
            Exception   exception = ctx.Server.GetLastError();

            string errorInfo = exception.InnerException.Message;

            System.Web.UI.Page page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page;
            if (page != null)
            {
                Label label = page.FindControl("statusbuttonclick") as Label;
                label.Text = String.Format(errorInfo);
            }
            HttpContext.Current.ClearError();
            HttpContext.Current.Application.Add("test", exception.InnerException.Message.ToString());
            Server.Transfer(appPath, false);
            //Response.Redirect(appPath, false);
        }
Пример #31
0
        public static short DebugMode(System.Web.UI.Page webPage, bool load = false)
        {
            if (load || debugMode < 0)
            {
                try
                {
                    string g = ((Literal)webPage.FindControl("DebugMode")).Text;
                    debugMode = System.Convert.ToInt16(g);
                    if (debugMode < 0)
                    {
                        debugMode = 0;
                    }
                }
                catch
                {
                    debugMode = 0;
                }
            }

            return(debugMode);
        }
        /// <summary>
        /// 儲存StudentNameVisibleMode的設定
        /// </summary>
        public void saveStudentNameVisibleModePresentation(System.Web.UI.Page WebPage, string strPaperID)
        {
            RadioButton rbVisible = ((RadioButton)(WebPage.FindControl("Form1").FindControl("rb-Visible")));

            //此功能是否有被開啟
            int intSelect = 1;

            if (rbVisible.Checked)
            {
                intSelect = 1;
            }
            else
            {
                intSelect = 0;
            }

            SqlDB  myDB   = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            string strSQL = "UPDATE Paper_Header SET bIsStudentNameVisible = '" + intSelect.ToString() + "' WHERE cPaperID = '" + strPaperID + "' ";

            myDB.ExecuteNonQuery(strSQL);
        }
        /// <summary>
        /// 儲存RandomSelection的設定
        /// </summary>
        public void saveRandomSelection(System.Web.UI.Page WebPage, string strPaperID)
        {
            RadioButton rbYes = ((RadioButton)(WebPage.FindControl("Form1").FindControl("rb-RandomSelection-Yes")));

            //此功能是否有被開啟
            int intSelect = 1;

            if (rbYes.Checked)
            {
                intSelect = 1;
            }
            else
            {
                intSelect = 0;
            }

            SqlDB  myDB   = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            string strSQL = "UPDATE Paper_Header SET bRandomSelection = '" + intSelect.ToString() + "' WHERE cPaperID = '" + strPaperID + "' ";

            myDB.ExecuteNonQuery(strSQL);
        }
Пример #34
0
        public void BindModel(object t, Page page)
        {
            foreach (PropertyInfo pi in t.GetType().GetProperties())
            {
                if (pi.CanWrite)
                {
                    Control ctrl = page.FindControl(pi.Name);
                    if (ctrl != null)
                    {
                        object ctrlVal = GetControl(ctrl);
                        try
                        {
                            core.SetPropertyValue(t, pi, ctrlVal);
                        }
                        catch (Exception)
                        {

                        }
                    }
                }
            }
        }
Пример #35
0
        /// <summary>
        /// Remove the script manager from the page form control.
        /// </summary>
        /// <param name="page">The page to remove the script manager from.</param>
        public static void RemoveScriptManager(System.Web.UI.Page page)
        {
            // Make sure the page reference exists.
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            // Get the existing script manager.
            string scriptManagerID = "ScriptManager99";

            // Has the script manager been created.
            if (IsEnabled())
            {
                // Find the script manager control on the page.
                // Remove the script manager from the page.
                Control scriptManager = page.FindControl(scriptManagerID);
                if (scriptManager != null)
                {
                    page.Form.Controls.Remove(scriptManager);
                }
            }
        }
		public static void UpdatePostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.AutoGenerateDeleteButton = true;
				d.AutoGenerateEditButton = true;
				d.AutoGenerateInsertButton = true;
				d.ItemCommand += new DetailsViewCommandEventHandler (d_ItemCommand);
				d.ItemUpdated += new DetailsViewUpdatedEventHandler (d_ItemUpdated);
				d.ItemUpdating += new DetailsViewUpdateEventHandler (d_ItemUpdating);
			}
		}
Пример #37
0
        private static void RegisterScript(Page page, JavaScriptLibrary jsl)
        {
            ClientResourceManager.RegisterScript(page, GetScriptPath(jsl), GetFileOrder(jsl), GetScriptLocation(jsl));

            //workaround to support IE specific script unti we move to IE version that no longer requires this
            if (jsl.LibraryName == CommonJs.jQueryFileUpload)
            {
                ClientResourceManager.RegisterScript(page,
                    "~/Resources/Shared/Scripts/jquery/jquery.iframe-transport.js");
            }

            if (Host.CdnEnabled && !String.IsNullOrEmpty(jsl.ObjectName))
            {
                string pagePortion;
                switch (jsl.PreferredScriptLocation)
                {
                    case ScriptLocation.PageHead:

                        pagePortion = "ClientDependencyHeadJs";
                        break;
                    case ScriptLocation.BodyBottom:
                        pagePortion = "ClientResourcesFormBottom";
                        break;
                    case ScriptLocation.BodyTop:
                        pagePortion = "BodySCRIPTS";
                        break;
                    default:
                        pagePortion = "BodySCRIPTS";
                        break;
                }
                Control scriptloader = page.FindControl(pagePortion);
                var fallback = new DnnJsIncludeFallback(jsl.ObjectName, VirtualPathUtility.ToAbsolute("~/Resources/libraries/" + jsl.LibraryName + "/" + Globals.FormatVersion(jsl.Version, "00", 3, "_") + "/" + jsl.FileName));
                if (scriptloader != null)
                {
                    //add the fallback control after script loader.
                    var index = scriptloader.Parent.Controls.IndexOf(scriptloader);
                    scriptloader.Parent.Controls.AddAt(index + 1, fallback);
                }
            }
        }
		public static void InsertPostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.ItemCommand += new DetailsViewCommandEventHandler (d_ItemCommand);
				d.ItemInserted += new DetailsViewInsertedEventHandler (d_ItemInserted);
				d.ItemInserting += new DetailsViewInsertEventHandler (d_ItemInserting);
			}
		}
		public static void ItemCreatedPostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.ItemCreated += new EventHandler (d_ItemCreated);
			}
		}
		public static void FireEvent_5_Init (Page p)
		{
			FormView d = p.FindControl ("FormView1") as FormView;
			if (d != null) {
				d.PageIndexChanged+=new EventHandler(d_PageIndexChanged);
				d.PageIndexChanging+=new FormViewPageEventHandler(d_PageIndexChanging);
			}
		}
        /// <summary>
        /// 儲存一個題目下所有選項的資料至Paper_NextStepBySelectionID
        /// </summary>
        /// <param name="WebPage"></param>
        /// <param name="strPaperID"></param>
        /// <param name="strQID"></param>
        /// <param name="strSelectionID"></param>
        /// <param name="intQuestionIndex"></param>
        public void saveNextStepBySelectionID(System.Web.UI.Page WebPage, string strPaperID, string strQID, int intQuestionIndex)
        {
            //DataReceiver myReceiver = new DataReceiver();

            //選項
            SQLString mySQL  = new SQLString();
            string    strSQL = mySQL.getAllSelections(strQID);

            SqlDB   myDB        = new SqlDB(System.Configuration.ConfigurationSettings.AppSettings["connstr"]);
            DataSet dsSelection = myDB.getDataSet(strSQL);

            if (dsSelection.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsSelection.Tables[0].Rows.Count; i++)
                {
                    string strSelectionID    = dsSelection.Tables[0].Rows[i]["cSelectionID"].ToString();
                    int    intSelectionIndex = Convert.ToInt32(dsSelection.Tables[0].Rows[i]["sSeq"]);
                    string strSelection      = dsSelection.Tables[0].Rows[i]["cSelection"].ToString();
                    bool   bSuggested        = Convert.ToBoolean(dsSelection.Tables[0].Rows[i]["bCaseSelect"]);

                    //取得題號下拉式選單被選取的內容
                    string       strDlIndexID = "dlSelection-Index-" + strSelectionID;
                    DropDownList dlIndex      = ((DropDownList)(WebPage.FindControl("Form1").FindControl(strDlIndexID)));
                    int          intNextIndex = Convert.ToInt32(dlIndex.SelectedItem.Value);

                    //取得Section下拉式選單被選取的內容
                    string       strDlSectionID = "dlSelection-Section-" + strSelectionID;
                    DropDownList dlSection      = ((DropDownList)(WebPage.FindControl("Form1").FindControl(strDlSectionID)));
                    string       strNextSection = "";
                    if (dlSection.SelectedItem != null)
                    {
                        strNextSection = dlSection.SelectedItem.Value;
                    }

                    //此選項的NextStep是By Section還是題號
                    int intNextMethod = 2;

                    //檢查此選項的NextStep是Section還是題號
                    string      strRbIndexID = "rbIndex-" + strSelectionID;
                    RadioButton rbIndex      = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbIndexID)));

                    string      strRbSectionID = "rbSection-" + strSelectionID;
                    RadioButton rbSection      = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbSectionID)));

                    string      strRbDefaultID = "rbDefault-" + strSelectionID;
                    RadioButton rbDefault      = ((RadioButton)(WebPage.FindControl("Form1").FindControl(strRbDefaultID)));

                    if (rbIndex.Checked == true)
                    {
                        if (intNextIndex == 0)
                        {
                            //結束Section
                            intNextMethod = 0;
                        }
                        else
                        {
                            //題號
                            intNextMethod = 2;
                        }
                    }
                    else if (rbSection.Checked == true)
                    {
                        //Section
                        intNextMethod = 1;
                    }
                    else
                    {
                        //Default
                        intNextMethod = 9999;
                        intNextIndex  = 9999;
                    }

                    //把資料存入Paper_NextStepBySelectionID
                    SQLString.SaveToPaper_NextStepBySelectionID(strPaperID, strQID, intQuestionIndex, strSelectionID, intSelectionIndex, intNextMethod, strNextSection, intNextIndex);
                }
            }
            dsSelection.Dispose();
        }
Пример #42
0
    public static void highlightMenu(string labelId, System.Web.UI.Page page)
    {
        System.Web.UI.HtmlControls.HtmlGenericControl div_highlight  = (System.Web.UI.HtmlControls.HtmlGenericControl)page.FindControl("dbtn_" + labelId);
        System.Web.UI.HtmlControls.HtmlGenericControl mimg_highlight = (System.Web.UI.HtmlControls.HtmlGenericControl)page.FindControl("mimg_" + labelId);
        System.Web.UI.HtmlControls.HtmlGenericControl himg_highlight = (System.Web.UI.HtmlControls.HtmlGenericControl)page.FindControl("himg_" + labelId);

        if (div_highlight != null)
        {
            div_highlight.Attributes.Add("class", "highlight");
        }
        if (mimg_highlight != null)
        {
            mimg_highlight.Attributes.Add("class", "selected");
        }
        if (himg_highlight != null)
        {
            himg_highlight.Attributes.Add("class", "selected");
        }
    }
		public static void FireEvent_2_Init (Page p)
		{
			FormView d = p.FindControl ("FormView1") as FormView;
			if (d != null) {
				d.ItemCreated += new EventHandler (d_ItemCreated);
			}
		}
		public static void CheckBoxList_Bug377703_2_OnInit (Page p)
		{
			CheckBoxList cbxl2 = p.FindControl ("cbxl2") as CheckBoxList;
			
			cbxl2.DataSource = new[] {
				new { ID = "x", Text = "X" },
				new { ID = "y", Text = "Y" },
				new { ID = "z", Text = "Z" },
			};
			cbxl2.DataValueField = "ID";
			cbxl2.DataTextField = "ID";
			cbxl2.DataBind();
		}
		public static void CheckBoxList_Bug578770_OnInit (Page p)
		{
			CheckBoxList test = p.FindControl ("test") as CheckBoxList;
			string[] weekDays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
			test.DataSource = weekDays;
			test.DataBind();
			test.Items[0].Enabled = false;
		}
		public static void _readControl (Page p)
		{
			ArrayList list = new ArrayList();
			recurcivefind (list, typeof (LinkButton), p.FindControl ("Wizard"));
			WebTest.CurrentTest.UserData = list;
		}
Пример #47
0
        /// <summary>
        /// Inject a reference to a CSS file into the page
        /// </summary>
        /// <param name="page">The current page object</param>
        /// <param name="name">the name of the css file - should be unique</param>
        /// <param name="file">the css file location - can be absolute or relative.</param>
        /// <param name="inHeader">true if css to be included in header, false if not</param>
        /// <param name="cssOrder">Where to include the css file in relation to the DNN css files - applies to DNN 6.1 installs only</param>
        internal static void InjectCssReference(System.Web.UI.Page page, string name, string file, bool inHeader, CssInjectOrder cssOrder)
        {
            int  major, minor, build, revision;
            bool useDotNetNukeWebClient = false, dnnWebClientOk = false;

            if (SafeDNNVersion(out major, out minor, out revision, out build))
            {
                if (major >= 6)
                {
                    if (major == 6 && minor < 1)
                    {
                        useDotNetNukeWebClient = false;
                    }
                    else
                    {
                        useDotNetNukeWebClient = true;
                    }
                }
            }
            if (useDotNetNukeWebClient)
            {
                //use reflection to inject the css reference
                int priority = GetCssPriority(cssOrder);
                //get the imbibe type
                Type imbibe = Type.GetType("DotNetNuke.Web.Client.ClientResourceManagement.ClientResourceManager, DotNetNuke.Web.Client");
                if (imbibe != null)
                {
                    //reflection call
                    //ClientResourceManager.RegisterScript(Page page, string filePath, int priority) // default provider
                    Type[]   paramTypes  = new Type[4];
                    object[] paramValues = new object[4];
                    paramTypes[0]  = typeof(System.Web.UI.Page);
                    paramValues[0] = page;
                    paramTypes[1]  = typeof(string);
                    paramValues[1] = file;
                    paramTypes[2]  = typeof(int);
                    paramValues[2] = priority;
                    paramTypes[3]  = typeof(string);
                    if (inHeader && inHeader)
                    {
                        paramValues[3] = "PageHeaderProvider";
                    }
                    else
                    {
                        paramValues[3] = "DnnBodyProvider";
                    }
                    //call the method to register the script via reflection
                    MethodInfo registerStyleSheetMethod = imbibe.GetMethod("RegisterStyleSheet", paramTypes);
                    if (registerStyleSheetMethod != null)
                    {
                        registerStyleSheetMethod.Invoke(null, paramValues);
                        dnnWebClientOk = true;    //worked OK
                    }
                }
            }
            //not on DNN 6.1, so use direct method to inject the header / body.
            //note that outcome position is pot luck based on calling code.
            if (!useDotNetNukeWebClient || dnnWebClientOk == false)
            {
                if (page.Header.FindControl(name) == null)
                {
                    //764 : xhtml compliance by using html link control which closes tag without separate closing tag
                    System.Web.UI.HtmlControls.HtmlLink cssFile = new System.Web.UI.HtmlControls.HtmlLink();
                    cssFile.Attributes.Add("rel", "stylesheet");
                    cssFile.Attributes.Add("href", file);
                    cssFile.Attributes.Add("type", "text/css");
                    cssFile.ID = name;
                    page.Header.Controls.Add(cssFile);
                }
                else
                {
                    if (page.FindControl(name) == null)
                    {
                        System.Web.UI.HtmlControls.HtmlLink cssFile = new System.Web.UI.HtmlControls.HtmlLink();
                        cssFile.Attributes.Add("rel", "stylesheet");
                        cssFile.Attributes.Add("href", file);
                        cssFile.Attributes.Add("type", "text/css");
                        cssFile.ID = name;
                        page.Controls.Add(cssFile);
                    }
                }
            }
        }
Пример #48
0
 public RefreshCatcher(System.Web.UI.Page PageToCheck)
 {
     m_Page        = PageToCheck;
     m_ctl_Refresh = (System.Web.UI.WebControls.HiddenField)PageToCheck.FindControl(REFRESH_NAME);
 }
		public static void FormView_Load (Page p)
		{
			if (p.IsPostBack) {
				DS data = (DS) p.FindControl ("Data") ;
				if (data == null)
					Assert.Fail ("Data soource control not created#1");
				data.DoRaiseDataSourceChangedEvent (new EventArgs ());
			}
		}
		public static void PagingPostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.PageIndexChanged += new EventHandler (d_PageIndexChanged);
				d.PageIndexChanging += new DetailsViewPageEventHandler (d_PageIndexChanging);
			}
		}
		public static void EditPostbackFireEvent_Init (Page p)
		{
			
			FormView d = p.FindControl ("FormView1") as FormView;
			if (d != null) {
				d.ModeChanged +=new EventHandler(d_ModeChanged);
				d.ModeChanging+=new FormViewModeEventHandler(d_ModeChanging);
				d.ItemCommand += new FormViewCommandEventHandler (d_ItemCommand);
				d.ItemUpdating += new FormViewUpdateEventHandler (d_ItemUpdating);
				d.ItemUpdated += new FormViewUpdatedEventHandler (d_ItemUpdated);
			}
		}
		public static void EditPostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.ModeChanging += new DetailsViewModeEventHandler (d_ModeChanging);
				d.ModeChanged += new EventHandler (d_ModeChanged);
			}
		}
		public static void FireEvent_4_Init (Page p)
		{
			FormView d = p.FindControl ("FormView1") as FormView;
			if (d != null) {
				d.ItemDeleting += new FormViewDeleteEventHandler (d_ItemDeleting);
				d.ItemDeleted += new FormViewDeletedEventHandler (d_ItemDeleted);
			}
		}
		public static void DeletePostback_Load (Page p)
		{
			DetailsView d = p.FindControl ("DetailsView1") as DetailsView;
			if (d != null) {
				d.ItemDeleting += new DetailsViewDeleteEventHandler (d_ItemDeleting);
				d.ItemDeleted += new DetailsViewDeletedEventHandler (d_ItemDeleted);
			}
		}
Пример #55
0
        public static Control GetPostBackControl(Page page)
        {
            Control postbackControlInstance = null;

            string postbackControlName = page.Request.Params.Get("__EVENTTARGET");

            if (postbackControlName != null && postbackControlName != string.Empty)
            {
                postbackControlInstance = page.FindControl(postbackControlName);
            }
            else
            {
                // handle the Button control postbacks
                for (int i = 0; i < page.Request.Form.Keys.Count; i++)
                {
                    postbackControlInstance = page.FindControl(page.Request.Form.Keys[i]);

                    if (postbackControlInstance is System.Web.UI.WebControls.Button)
                    {
                        return postbackControlInstance;
                    }
                }
            }

            // handle the ImageButton postbacks

            if (postbackControlInstance == null)
            {
                for (int i = 0; i < page.Request.Form.Count; i++)
                {
                    if ((page.Request.Form.Keys[i].EndsWith(".x")) || (page.Request.Form.Keys[i].EndsWith(".y")))
                    {
                        postbackControlInstance = page.FindControl(page.Request.Form.Keys[i].Substring(0, page.Request.Form.Keys[i].Length - 2));

                        return postbackControlInstance;
                    }
                }
            }

            return postbackControlInstance;
        }
Пример #56
0
        /// <summary>
        /// The UpdateBtn_Click event handler on this Page is used to either
        /// create or update a row. It uses the Rainbow.UserDefinedTableDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnUpdate(EventArgs e)
        {
            // Calling base we check if the user has rights on updating
            base.OnUpdate(e);

            UserDefinedTableDB objUserDefinedTable = new UserDefinedTableDB();
            bool   ValidInput = true;
            string strMessage = string.Empty;

            SqlDataReader dr = objUserDefinedTable.GetUserDefinedFields(ModuleID);

            try
            {
                while (dr.Read())
                {
                    //if ( Request.Form[prefix + dr["FieldTitle"]] != null && Request.Form[prefix + dr["FieldTitle"]].ToString().Length != 0 )
                    if (Request.Form[prefix + dr["FieldTitle"]] != null)
                    {
                        switch (dr["FieldType"].ToString())
                        {
                        case "Int32":
                            try
                            {
                                int obj = int.Parse(Request.Form[prefix + dr["FieldTitle"].ToString()]);
                            }
                            catch
                            {
                                strMessage += "<br>" + dr["FieldTitle"].ToString() + " " + General.GetString("UDT_VALIDINTEGER", "must contain a valid integer value");
                                ValidInput  = false;
                            }
                            break;

                        case "Decimal":
                            try
                            {
                                Decimal obj = Decimal.Parse(Request.Form[prefix + dr["FieldTitle"].ToString()]);
                            }
                            catch
                            {
                                strMessage += "<br>" + dr["FieldTitle"].ToString() + " " + General.GetString("UDT_VALIDDECIMAL", "must contain a valid decimal value");
                                ValidInput  = false;
                            }
                            break;

                        case "DateTime":
                            try
                            {
                                DateTime obj = DateTime.Parse(Request.Form[prefix + dr["FieldTitle"].ToString()]);
                            }
                            catch
                            {
                                strMessage += "<br>" + dr["FieldTitle"].ToString() + " " + General.GetString("UDT_VALIDDATE", "must contain a valid date value");
                                ValidInput  = false;
                            }
                            break;

                        case "Boolean":
                            try
                            {
                                bool obj = bool.Parse(Request.Form[prefix + dr["FieldTitle"].ToString()]);
                            }
                            catch
                            {
                                strMessage += "<br>" + dr["FieldTitle"].ToString() + " " + General.GetString("UDT_VALIDBOOLEAN", "must contain a valid true/false value");
                                ValidInput  = false;
                            }
                            break;
                        }
                    }
                }
            }
            finally
            {
                dr.Close();
            }

            if (ValidInput)
            {
                if (UserDefinedRowID == -1)
                {
                    UserDefinedRowID = objUserDefinedTable.AddUserDefinedRow(ModuleID, out UserDefinedRowID);
                }

                dr = objUserDefinedTable.GetUserDefinedFields(ModuleID);
                try
                {
                    while (dr.Read())
                    {
                        string fieldValue = Request.Form[prefix + dr["FieldTitle"].ToString()];

                        if (dr["FieldType"].ToString() == "File" || dr["FieldType"].ToString() == "Image")
                        {
                            HtmlInputFile fileControl = (HtmlInputFile)Page.FindControl(prefix + dr["FieldTitle"].ToString() + "_Upload");
                            if (fileControl.PostedFile.ContentLength > 0)
                            {
                                fieldValue = fileControl.PostedFile.FileName.Substring(fileControl.PostedFile.FileName.LastIndexOf("\\") + 1);

                                string pathToSave = string.Empty;

                                if (dr["FieldType"].ToString() == "Image")
                                {
                                    pathToSave = Server.MapPath(((SettingItem)moduleSettings["ImagePath"]).FullPath) + "\\";
                                }
                                else
                                {
                                    pathToSave = Server.MapPath(((SettingItem)moduleSettings["DocumentPath"]).FullPath) + "\\";
                                }

                                try
                                {
                                    fileControl.PostedFile.SaveAs(pathToSave + fieldValue);
                                }
                                catch (DirectoryNotFoundException ex)
                                {
                                    // If the directory is not found, create and then save
                                    Directory.CreateDirectory(pathToSave);
                                    //System.IO.File.Delete(pathToSave + fieldValue);
                                    fileControl.PostedFile.SaveAs(pathToSave + fieldValue);

                                    //This line is here to supress the warning
                                    ex.ToString();
                                }
                            }
                        }

                        objUserDefinedTable.UpdateUserDefinedData(UserDefinedRowID, int.Parse(dr["UserDefinedFieldID"].ToString()), fieldValue);
                    }
                }
                finally
                {
                    dr.Close();
                }

                objUserDefinedTable.UpdateUserDefinedRow(UserDefinedRowID);

                // Redirect back to the portal home page
                this.RedirectBackToReferringPage();
            }
            else
            {
                lblMessage.Text = strMessage;
            }
        }