RSS
 

Archive for the ‘control’ Category

Know the control which caused the postback

23 Jan

I got this from some site. It can be used to know the control which caused the postback.

 public static Control GetPostBackControl(Page thePage)
    {
        Control myControl = null;
        string ctrlName = thePage.Request.Params.Get(“__EVENTTARGET”);
        if (((ctrlName != null) & (ctrlName != string.Empty)))
        {
            myControl = thePage.FindControl(ctrlName);
        }
        else
        {
            foreach (string Item in thePage.Request.Form)
            {
                Control c = thePage.FindControl(Item);
                if (((c) is System.Web.UI.WebControls.Button))
                {
                    myControl = c;
                }
            }

        }
        return myControl;
    }

 
 

How to Register User Controls and Custom Controls in Web.config

23 Jan

If we register controls in the web.config, we don’t have to register the control on each page. This is useful, if we have to use the same control on several pages.

Help Link