|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Why usercontrol won't allow Request.Cookiesusercontrol and instantiate a class and call a property in that class which calls Request.Cookies. The instantiated class inherits the Page class. Why won't this work? namespace ui { public partial class topNav : System.Web.UI.UserControl { BaseUpdatePage SharedBaseMethods = new BaseUpdatePage(); protected void Page_Load(object sender, System.EventArgs e) { lblUserAndDatabase.Text = "User: " + SharedBaseMethods.UserID + " :: " + DateTime.Now.ToLongDateString() + " :: Database: " + SharedBaseMethods. }Database; } } -- Message posted via DotNetMonster.com http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200512/1 Just because you instantiate a page class does not mean it has a
HttpContext. There is no point instantiating a Page class like that, put your shared methods in a normal class and use HttpContext.Current.Request to get the threads active context. Stephen "Andy Sutorius via DotNetMonster.com" <u9025@uwe> wrote in message news:583cab0b00fb7@uwe...Show quoteHide quote > I'm getting an error, Request is not available in this context, when I run > a > usercontrol and instantiate a class and call a property in that class > which > calls Request.Cookies. The instantiated class inherits the Page class. Why > won't this work? > > namespace ui > { > public partial class topNav : System.Web.UI.UserControl > { > BaseUpdatePage SharedBaseMethods = new BaseUpdatePage(); > > protected void Page_Load(object sender, System.EventArgs e) > { > lblUserAndDatabase.Text = "User: " + SharedBaseMethods.UserID + > " > :: " + DateTime.Now.ToLongDateString() + " :: Database: " + > SharedBaseMethods. > Database; > } > } > } > > -- > Message posted via DotNetMonster.com > http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net-web-controls/200512/1
VS2005 is a PIECE of Garbage and is bug Ridden
Checkbox and Javascript drop down list box - client side code won't execute OnSelectedIndexChange issues using webbrowser in a service Display an images in Datagrid Custom control that ingerits from textbox Losing Session Values Lost with User Controls client side access. gridview.boundfield.dataformatstring doesn't work |
|||||||||||||||||||||||