CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: Date Entered: 1/25/2006 12:49:08 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 5 Views: 26 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
Sailu_tp
Asp.Net User
VS 2005: Why and How tos?1/25/2006 12:49:08 AM

0

Hi
I am baffled with some stuff i am noticing in VS 2005.
Please let me know if i am doing something incorrect.

Here are a few things:

Issue 1:

1. I created a  base user control called MYUserControlBase.
2. I added a property called MYProperty with internal modifier.
3. I created another user control called MyUserControl which inherits MYUserCOntrolBase.
4. Now, when i try to access the property MYProperty (by typing this.) in MyUserCOntrol, i notice the intellisense does not display MyProperty.
5. Also, when i type in this and try to access NamingContainer property in MyUserControl i cannot seem to access it, but if i change the inheritance page to UserControl instead of MyUserCOntrol i can access it?

Is this expected?

Issue 2:

1. I have added a new WebForm called WebForm1.aspx.
2. I have dragged the user control that i have created in the above steps on to this WebForm1.
3. Now, in the usercontrol, MyUserControl.ascx, i typed:
(()this.Page) and tried to cast it to the page, but i can't seem to do it.

Is this also expected?

Issue 3:

1. I have added namespace Test to a class and tried building it, i get this error:

Error 3 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). C:\Projects\MyProject\WebUserControl.ascx.cs 16 33 C:\...\


Please let me know if you have any answers.
Thanks.

ScottGu
Asp.Net User
Re: VS 2005: Why and How tos?1/25/2006 5:22:31 AM

0

I can help answer a few questions:

Issue #1: The reason the property in the base class isn't being seen by the sub-class is because the property was defined with an "internal" accessor instead of protected.  Classes in the app_code directory are now compiled in a separate assembly from the user-control -- so internal members can't be accessed (since these only work within the same assembly).  Changing the accessor to protected will fix this.

Issue #2: In general I'd recommend not doing this approach (since you end up with a control that is in a page container having intimate knowledge of the page -- which breaks some encapsulation rules).  If you do want to-do this, what I'd recommend is declaring a page base class in your app_code directory for your page -- and then having the user-control cast against this when accessing the page.  That way the page contract is explict, and you can re-use the control across multiple page.

Issue #3: The problem you have here is that you updated the namespace in only one place (the code-behind file).  You also need to go into the .aspx file and modify the "inherits" attribute to qualify the namespace (for example: inherits="MyNamespace.MyPageClass").

Hope this helps,

Scott

Sailu_tp
Asp.Net User
Re: VS 2005: Why and How tos?1/25/2006 4:19:59 PM

0

Hi Scott
It is a pleasure receiving a response from you.  Thank you.

Issues 1 and 3 are good, understood.
Issue 2 i got it working but i am wondering what are the advantages of this approach over the normal one.

And you say:

::Classes in the app_code directory are now compiled in a separate assembly from the ::user-control

Where is the assembly?
Thanks.

Sailu_tp
Asp.Net User
Re: VS 2005: Why and How tos?1/25/2006 4:42:05 PM

0

Hi Scott

Extending the example in Issue 2:

1. I have added a new WebForm called WebForm1.aspx.
2. I have dragged the user control (UC1.ascx) on to this WebForm1.
3. Then dragged another UC2.ascx onto WebForm1.aspx.
4. UC1 is on left and UC2 is on right side of WebForm, both use III party controls which have ajax capable functionality built in.
5. User selects some fields in UC1 and then makes selections in UC2 when we call certain Callback events decalared in UC2.ascx.cs. At this point, when the callback event in UC2 is called/triggered, if i want to access the values of fields in UC1, how to do. In .Net 1.1 i would do it like this:

In UC2.ascx.cs:
 ((ASP.WebForm1)this.Page)

But this changed in .Net 2.0. Please let me know if you have any suggestions.
Thanks.


 

ScottGu
Asp.Net User
Re: VS 2005: Why and How tos?1/26/2006 5:37:58 AM

0

Hi Sailu,

If I understand you right, you want usercontrol1 to be able to access the values of usercontrol2?

You could do this by doing two steps:

1) Add a <%@ Reference control="usercontrol.ascx" %> reference in usercontrol1 that points to the .ascx file of usercontrol2.  This should be the first line of the usercontrol1.ascx file.  This will then allow usercontrol1 to cast and access a usercontrol2 type.

2) Then within the code of usercontrol1 you could write code like:

usercontrol2 uc2 = (usercontrol2) this.Page.FindControl("usercontrol1");

string foo = uc2.property;

Hope this helps,

Scott

Sailu_tp
Asp.Net User
Re: VS 2005: Why and How tos?1/27/2006 2:53:13 AM

0

Thanks Scott.
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
An introduction to programming using Visual Basic 2005 Authors: David I. Schneider, Pages: 736, Published: 2006
Practical software factories in .NET Authors: Gunther Lenz, Christoph Wienands, Jack Greenfield, Wojtek Kozaczynski, Pages: 214, Published: 2006
Professional Software Testing with Visual Studio 2005 Team System: Tools for Software Developers and Test Engineers Authors: Tom Arnold, Dominic Hopton, Andy Leonard, Mike Frost, Pages: 372, Published: 2007
Professional Visual Studio 2005 Team System Authors: Jean-Luc David, Tony Loton, Erik Gunvaldson, Noah Coad, Christopher Bowen, Darren Jefford, Pages: 700, Published: 2006
C# 2005 for dummies Authors: Stephen R. Davis, Charles Sphar, Chuck Sphar, Pages: 406, Published: 2005

Web:
Build Instructions (Windows) ‎(Chromium Developer Documentation)‎ You probably had installed the SDK prior to VS2005. Open Visual Studio 2005, Tools > Options... > Projects and Solutions > VC++ Directories (Assuming your ...
Team System Home Resources to learn more about Visual Studio Team System 2010. Friday, Apr 10 by jeffbe ... Visual Studio 2005 Team Edition for Software Architects FAQ ...
Total .NET SourceBook - for Visual Studio 2005 - Summary NET SourceBook - for Visual Studio 2005 - Annual Subscription to Code Webservice 1 Developer Annual Subscription License, Total .NET SourceBook - for Visual ...
Alik Levin's : VS 2005 Web Application Project - Resources It is a bundle of resources for VS 2005 Web Application Project feature . ... VS 2005 Web Application Project V1.0 Released · Introduction to Web ...
JetBrains .NET Tools Blog » Blog Archive » ReSharper 2.5 for ... Before we all leave for various seasonal holidays, we wanted to get ReSharper for Visual Studio 2005 version 2.5 out to you. ...

App_Code folder bug - ng.asp-net-forum.visual_studio_2005 When you manually create an App_Code folder in a VS2005 project, ... Using Multiple Programming Languages ... vs 2005 how to create a new web project in c# ...
The project has not been converted - ng.asp-net-forum ... vs 2005 b2 - where to download/buy when available · how do we generate the xml documentation from asp.net web project. how to generate resource files? ...
Intellisense and Custom Configuration Sections in web.config - ng ... I have been trying to get intellisense to work (VS 2005 Beta 2 Release) .... is there a quickfix feature/plugin for vs 2005 similar to the one in eclipse? ...
Can't Change Encoding Settings - macromedia.flash.flash_media_encoder Creative ZEN Vs. iPod Nano 3rd gen. Part 1 A comparison of the new Creative ZEN MP3 player to the new 3rd generation iPod Nano from Apple. ...

Videos:
Tales of Symphonia - Level 6 Colette vs Abyssion Version 1 A battle against Abyssion on Mania with just Colette at level 6. Colette was kept at level 6 by buying Combo EXP at the Grade Shop, but I didn't ...
Zatu vs Bha // Semifinal Madrid 2005 Semifinal de la Batalla de Gallos 2005 en la Sala Caracol, posiblemente una de las mejores batallas que existen, no está entera, no encontre el ...
Divergence - Aaron Kwok vs. Daniel Wu Aaron Kwok fights Daniel Wu in this scrappy but quality brutal fight sequence. Cast Daniel Wu Yin-Cho ... Koo/Coke Ekin Cheng Yee ...












macro to show warning message during compilation

creating new project issue

datalist control data source problem

source controll management tool?

object test bench

installation of visual studio 2005 while keeping visual studio 2003 on the same machine

#regions: is there a way to have vs.net automatically collaspe all regions when a .cs file is opened?

increment time of program exection

build the multi assembly

how to bind menu control with dynamic data

what happened to "format document"?

how to stop the refactoring that happens when you rename a control in the aspx designer?

login feature

want to use c# as an alternative to java

creating submit buttons in asp.net 2.0

css validation: 'position' is not a valid css property name - on aspx page

visualsourcesafe 2005 or free webbased interface

error wheb run report created by crystal report v10

anyway to stop asp.net from uncollapsing code in html source view?

regarding word project

emailing build status in team server

team builds & web deployment project

vs 2005 - highlighting variables

file or ftp explorer for visual studio 2005

newbie question - visual studio 2005 sql admin tools

ide not showing custom control in vs 2005

visual studio 2005 - vista enterprise - dropping assembly on the toolbox

how can i change the toolbox shape?

cant get flash component

making vs 2005 working with sql server 2005 (non express)

"obj" folder in library projects

upload a new stored procedure to published site

webdeployment remove not english characters

how to add custom database item templates?

how to validate xml file against dtd or scheam in vs.net 2005?

strong password enforcement, how do i turn it off when developing?

debugger: unable to start ie

control events in vs 2005

asp.net nativerd.dll

code behind best practice

extending sqldatasource - where's the toolbox icon?

upgrade questions

update forms

visual studio hangs when background process starts (urgent help)!!!

where's my root namespace? trying to ref page, master, usercontrol true types from other types.

vs2005 and solution

how to use relative paths for references?

memberadministration in vwd

partial classes

how do i create a stored procedure in vs2005 for sql2000 and be able to debug the stored procedure?

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT