473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Page/Controls Inheritance in ASP.NET 2.0

hi guys,

I am having the following problem:
I am trying to access some textbox & dropdown controls from my function
located in the app_code folder but I can't see them, it complains about not
being declared! or not found.

it was working in VS 2003 before the migration; since there is no App_Code
but now since I moved it, I can't seem to figure out how to make it see the
controls sitting on the aspx form from a shared class sitting in the
app_code folder?

for example lets say the function is:

public shared MarkScheduleLength()

dim i as integer
dim s as string

i = ctype(txtLength.Text,integer) 'it complains about txtLength.Text
is not declared
s = cmbName.SelectedValue 'it complains about cmbName is not
declared

........

I don't want to create an instance of the form because I am trying to
capture the exact value of that control at that time(as it changes) and not
creating a new instance of it with a new value, I am trying to capture
cmbName_SelectedIndexChanges(....) everytime the user changes the drop down
menu selection

how can I work around this?. I have a lot of functions and methods that
access textboxes, dropdown menus, labels, ...etc as their value changes at
runtime and now I am stuck, it can not see any of them.

did Microsoft disable controls access because of this move to App_Code
folder? they didn't think of that?

Please let me know
thanks
Jan 12 '07 #1
11 1369
you pages shoudl implement an interface, then the appcode can cast the
current page to the interface and access the form fields. or simular to
version one the appcode is a base page (which defines the fields) and
your pages inherit from it

-- bruce (sqlwork.com)

netasp wrote:
hi guys,

I am having the following problem:
I am trying to access some textbox & dropdown controls from my function
located in the app_code folder but I can't see them, it complains about not
being declared! or not found.

it was working in VS 2003 before the migration; since there is no App_Code
but now since I moved it, I can't seem to figure out how to make it see the
controls sitting on the aspx form from a shared class sitting in the
app_code folder?

for example lets say the function is:

public shared MarkScheduleLength()

dim i as integer
dim s as string

i = ctype(txtLength.Text,integer) 'it complains about txtLength.Text
is not declared
s = cmbName.SelectedValue 'it complains about cmbName is not
declared

.......

I don't want to create an instance of the form because I am trying to
capture the exact value of that control at that time(as it changes) and not
creating a new instance of it with a new value, I am trying to capture
cmbName_SelectedIndexChanges(....) everytime the user changes the drop down
menu selection

how can I work around this?. I have a lot of functions and methods that
access textboxes, dropdown menus, labels, ...etc as their value changes at
runtime and now I am stuck, it can not see any of them.

did Microsoft disable controls access because of this move to App_Code
folder? they didn't think of that?

Please let me know
thanks

Jan 12 '07 #2
Hi netasp,

Would you please tell me more about how the code is written in ASP.NET 1.1?
This way I could give more detailed suggestion on how to migrate them to
ASP.NET 2.0 successfully. Thanks.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 15 '07 #3
thanks Walter for your reply,

when adding a new web form in VS 2003, usually viewing the code behind for
that form will let you write any method or function and referencing any web
control placed on the form without any problems, for example writing a
function that grabs a string value from a textbox is as easy as saying:
dim str as string = me.TextBox1.Text

but with visual studio 2005 I can't do this simple way because the class for
that form is placed in an app_code folder and it will not see non of the
controls on the web form, so saying:
dim str as string = me.TextBox1.Text will not work and it complains about
the TextBox1 is not defined. in more details, I have a function was working
in visual studio 2003 that calls a stored procedure in sql server 2005, this
function passes a variables (3 variables) from a 3 textboxes on the form.
And I am calling this function everytime the user changes the value of one
of these textboxes.

now since the migration, visual studio 2005 puts all classes under Ap_Code
folder (as one of their new features!!) moving my function under the
App_Code folder prevents me from calling/Getting the values of those
textboxes as they change why? because the class can't see those controls
sitting on the form!

thanks for your help.
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:1t**************@TK2MSFTNGHUB02.phx.gbl...
Hi netasp,

Would you please tell me more about how the code is written in ASP.NET
1.1?
This way I could give more detailed suggestion on how to migrate them to
ASP.NET 2.0 successfully. Thanks.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 15 '07 #4
thanks Bruce for your reply,

thats a complete re-write, specially if you have more than 100
methods/functions then it would be cleaner to re-write the application then
migration, i don't think Microsoft would make us make something stupid like
that. there must something easier then writing interface or creating an
instance of the class everytime you are trying to get a value from a textbox
or dropdown menu which should be no-brainer!

i don't know why Microsoft would do something like that!

i might be wrong, i don't know...

thanks
"bruce barker" <no****@nospam.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
you pages shoudl implement an interface, then the appcode can cast the
current page to the interface and access the form fields. or simular to
version one the appcode is a base page (which defines the fields) and your
pages inherit from it

-- bruce (sqlwork.com)

netasp wrote:
>hi guys,

I am having the following problem:
I am trying to access some textbox & dropdown controls from my function
located in the app_code folder but I can't see them, it complains about
not being declared! or not found.

it was working in VS 2003 before the migration; since there is no
App_Code but now since I moved it, I can't seem to figure out how to make
it see the controls sitting on the aspx form from a shared class sitting
in the app_code folder?

for example lets say the function is:

public shared MarkScheduleLength()

dim i as integer
dim s as string

i = ctype(txtLength.Text,integer) 'it complains about
txtLength.Text is not declared
s = cmbName.SelectedValue 'it complains about cmbName is not
declared

.......

I don't want to create an instance of the form because I am trying to
capture the exact value of that control at that time(as it changes) and
not creating a new instance of it with a new value, I am trying to
capture cmbName_SelectedIndexChanges(....) everytime the user changes the
drop down menu selection

how can I work around this?. I have a lot of functions and methods that
access textboxes, dropdown menus, labels, ...etc as their value changes
at runtime and now I am stuck, it can not see any of them.

did Microsoft disable controls access because of this move to App_Code
folder? they didn't think of that?

Please let me know
thanks
Jan 15 '07 #5
Hi netasp,

Do you mean that code files such as Default.aspx.cs are moved to App_Code
directory too? The App_Code should be used only to place other classes
(i.e. not the code behind file of web form). The code behind files such as
Default.aspx.cs should stay in the same directory with its web form file
(*.aspx or *.ascx).

Would you please tell me some detailed steps how you migrated the 1.1
projects? Based on my understanding, the migration wizard will NOT create
the App_code folder and put all the source files there for you.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 16 '07 #6
netasp wrote:
thats a complete re-write, specially if you have more than 100
methods/functions then it would be cleaner to re-write the application then
migration, i don't think Microsoft would make us make something stupid like
that.
Yes, Microsoft would. :) But Microsoft has already rectified the
situation with Service Pack 1.
http://blogs.vertigosoftware.com/tea...1/03/4057.aspx

Jan 16 '07 #7
Also, as other community members suggested, the Web Application Project
add-on for VS2005 (included in SP1 or as standalone installation) will
maintain the same web project model as in VS2003. Therefore you will be
still be able to use familiar project model with new features introduced in
ASP.NET 2.0.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 16 '07 #9
hello Walter,

the migration does not move everything to the App_Code folder, only the
classes (.vb)
so whatever methods and functions i used to have behinde any aspx form,
after migration that class ONLY will move into the App_Code folder and .aspx
form will stay in its place. so for example:
Default.aspx would stay in its place and Default.aspx.vb would move into the
App_Code folder and that what is causing the problem.

Now, what marss has suggested is every interesting and i am going to check
it out, I didn't know about Website vs Web Application and I usually create
New WebSite !! because its the obvious thing to any user.

sorry about the late reply since all of these posts are not showing in my
outlook express for some reason

"Walter Wang [MSFT]" wrote:
Also, as other community members suggested, the Web Application Project
add-on for VS2005 (included in SP1 or as standalone installation) will
maintain the same web project model as in VS2003. Therefore you will be
still be able to use familiar project model with new features introduced in
ASP.NET 2.0.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 26 '07 #10
Hi netasp,

Thank you for update.

I'm still not able to reproduce the issue from VS2003 to VS2005 (sp1 or no
sp1). Anyway, the Web Application Project add-on should maintain the
similar web project model from VS2003, therefore I believe this should not
have this issue on your side. Please let me know the result. Thanks.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 29 '07 #11
hi Walter,

yeah, the SP1 fixed this problem by bringing back the web application project.

thank you very much for your support

"Walter Wang [MSFT]" wrote:
Hi netasp,

Thank you for update.

I'm still not able to reproduce the issue from VS2003 to VS2005 (sp1 or no
sp1). Anyway, the Web Application Project add-on should maintain the
similar web project model from VS2003, therefore I believe this should not
have this issue on your side. Please let me know the result. Thanks.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 29 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Das | last post by:
Hi All, Where does asp.net stores the objects declared in the page. I have a method where I want to loop through all the controls(textbox, HtmlInputText) within the page. I want to in which...
0
by: VB Programmer | last post by:
I have 2 webforms. When I print out the page.Controls(1).tostring variable one says "HtmlForm", the other "HtmlGenericControl". How can I change the first one to "HtmlForm"? ?...
2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
2
by: sck10 | last post by:
Hello, I am looping through each control using the following to find a particular control (strFindCtl = "tbxCompetitor" & strForLoop1 & "Product"). For ctrRow = 1 To 3 strForLoop1 = "0" &...
5
by: Mattia Saccotelli | last post by:
Hi to all. I'm trying to auto-save a form to XML using Page.Controls property. Almost everything is fine, except a really weird behavior with the HtmlTextArea control. I noticed that if it has a...
11
by: Frank Esser | last post by:
Hi, I created an ASP.NET page (test.aspx) with some web controls in GridLayout (Design time). When I look at the collection page.controls by foreach (Control ctrl in Page.Controls) { ....
7
by: Rodusa | last post by:
I am trying to loop all controls in a form with no success. For example, Let's say we place three TextBoxes in the form and we use the code below: foreach (Control c in Page.Controls) {...
3
by: Avon | last post by:
Hi friends, I need of some help, I have this code: For Each t As TextBox In Page.Controls ' here is the error t.Text = "test" Next But I am getting this error: Unable to cast object of type...
0
by: pargat.singh | last post by:
Hi : I am using Master/Child page in VS2005 and i wrote generic function to show/hide controls which works fine if i don't use master/child .Below is my function which work fine for single page...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.