Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
|
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2010, 02:09 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default Passing data from user control to page

I have a login form defined in a user control. The user control is then defined in my master page so that it appears on every page of the website. I managed to run all of the application security code through the code behind of the user control and when I'm done I simply have a DataTable with the current user's information so I can customize the page. This gives me one simple point of contact between the site wide security and each content page.

...So how do I access the DataTable from the Page_Load event of each of the content pages?
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old February 10th, 2010, 02:52 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

What you've described appears to be a rather odd way of doing things (at least to me). Be that as it may, the normal way of interacting with a user control from a Page is to expose public properties on the user control.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 10th, 2010, 07:00 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

You were right, getting at the properties of the user control was awful. I just dumped it and wrote the code into the master page. Then I was able to access the DataTable through a master page method.

On postback, however, I don't have access to the DataTable. Once you refresh the page or request a new page, the DataTable is available thereafter.

I tried adding code to the function which processes the login, but logging in behaves the same with or without the code. How do I access the DataTable immediately after logging in?
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.

Last edited by chroniclemaster1; February 10th, 2010 at 07:13 PM..
 
Old February 11th, 2010, 12:54 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I'm sorry, what's the DataTable for again exactly?
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old February 13th, 2010, 06:06 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

:) Got it!

It may not be elegant, but I've triggered an automatic page refresh on log in and log out so that the page displays the correct behavior. I used Request.Url to grab the current url of the content page, then I stuck the AbsoluteUri property into a Response.Redirect. Phew!
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old February 14th, 2010, 03:03 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I haven't been following this thread but it seems you are trying to build an "Identity Principle".
Google "asp.net authorisation" and and Im sure you will find far more elegant and stable ways of doing this.
__________________
======================================
"They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad."
--Shakespeare
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a DataSource to a user control hpox ASP.NET 2.0 Professional 1 January 8th, 2007 11:04 AM
passing parameters to user control jbeynon ASP.NET 2.0 Professional 0 August 30th, 2006 06:18 AM
Passing as object as a Param to a Web User Control MixedCode General .NET 2 December 8th, 2004 11:36 AM
Passing a Value to a User Control DC Ross ASP.NET 1.0 and 1.1 Basics 2 February 17th, 2004 06:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.