Showing posts with label property. Show all posts
Showing posts with label property. Show all posts
Friday, May 20, 2011
Add Custom Properties to ASP Membership User
Blog has been moved to :
http://robfine.com/aspnet/AddCustomPropertiestoASPMembershipUser
Thursday, January 20, 2011
Reference Removed Build Visual Studio 2010
Having trouble with a reference you imported when you try to build or debug an application with Visual Studio 2010?
I noticed an issue with VS2010 when I was creating a simple VB.NET console application using Google's GData Client API. I began by adding the reference to a .dll file and then adding a "Imports Google.GData.Client" to the top of my code. All pretty standard right?
I was then able to write out the code for my application using this API; everything seemed to be working fine. Intellisense picked up the classes and all. Then I tried to debug and everything fell apart.
Suddenly it was if I had never added the reference to my class. I was getting Type not defined errors and namespace issues with my imports statement. I checked my references and found my expected .dlls, but went ahead and re-added them anyways. All my errors cleared out and everything again looked fine. I tried to build and debug again and kept hitting the same issue.
After a long time, I finally found a solution!
Go to your application's properties, click on the Compile tab and set the "Target framework (all configurations):" dropdown from ".NET Framework 4 Client Profile" to ".NET Framework 4"

Click OK and save. Your applications will probably shut down all windows, but now you should be able to debug and build your application successfully (assuming you have no other errors). At least the reference issue will be solved.
I noticed an issue with VS2010 when I was creating a simple VB.NET console application using Google's GData Client API. I began by adding the reference to a .dll file and then adding a "Imports Google.GData.Client" to the top of my code. All pretty standard right?
I was then able to write out the code for my application using this API; everything seemed to be working fine. Intellisense picked up the classes and all. Then I tried to debug and everything fell apart.
Suddenly it was if I had never added the reference to my class. I was getting Type not defined errors and namespace issues with my imports statement. I checked my references and found my expected .dlls, but went ahead and re-added them anyways. All my errors cleared out and everything again looked fine. I tried to build and debug again and kept hitting the same issue.
After a long time, I finally found a solution!
Go to your application's properties, click on the Compile tab and set the "Target framework (all configurations):" dropdown from ".NET Framework 4 Client Profile" to ".NET Framework 4"

Click OK and save. Your applications will probably shut down all windows, but now you should be able to debug and build your application successfully (assuming you have no other errors). At least the reference issue will be solved.
Labels:
console,
framework,
import,
property,
reference,
target framework,
vb.net,
Visual Studio 2010
Monday, December 13, 2010
How to Set MasterPage Variables from Content Page
Need to send information from your content page to your master page?
Despite what you may have read on a couple blogs, IT CAN BE DONE!
Here's how.
Suppose I have a variable in my code behind my master page that I want to set based on what content page is opened. In my particular case, I'm going to use an example of a menu that I will only show while browsing certain pages in my website.
The first thing I need to do is create a variable within my master page:
Private _showMenu As Boolean = False
I can use this variable later within my master page's Me.Load function to set the menu control to visible or not. Now, I need a way to interact with the Master page for this variable, so I will make a simple Property for the page:
We are now done with the MasterPage, which for my example I have named "MyAwesomeMasterPage". Moving on to content pages, for each page I want to communicate with my master page, all I have to do is add one easy line in the initialization of the page. I do it so early, just in case I need to access the variable early in my master page's loading.
By casting my content page's masterpage as the MyAwesomeMasterPage page that I created, it is now aware of the Public Property that I created for it.
Despite what you may have read on a couple blogs, IT CAN BE DONE!
Here's how.
Suppose I have a variable in my code behind my master page that I want to set based on what content page is opened. In my particular case, I'm going to use an example of a menu that I will only show while browsing certain pages in my website.
The first thing I need to do is create a variable within my master page:
Private _showMenu As Boolean = False
I can use this variable later within my master page's Me.Load function to set the menu control to visible or not. Now, I need a way to interact with the Master page for this variable, so I will make a simple Property for the page:
Public Property ShowMenu() As Boolean
Get
Return _showMenu
End Get
Set(ByVal value As Boolean)
_showMenu = value
End Set
End Property
We are now done with the MasterPage, which for my example I have named "MyAwesomeMasterPage". Moving on to content pages, for each page I want to communicate with my master page, all I have to do is add one easy line in the initialization of the page. I do it so early, just in case I need to access the variable early in my master page's loading.
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
CType(Master, MyAwesomeMasterPage).ShowMenu = True
End Sub
By casting my content page's masterpage as the MyAwesomeMasterPage page that I created, it is now aware of the Public Property that I created for it.