页面/控件ASP.NET 2.0中的继承 [英] Page/Controls Inheritance in ASP.NET 2.0

查看:63
本文介绍了页面/控件ASP.NET 2.0中的继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我遇到以下问题:

我正在尝试访问某些文本框&从我的函数下拉控件

位于app_code文件夹但我看不到它们,它抱怨没有

被声明!或者没有找到。


它在迁移之前在VS 2003中工作;因为没有App_Code

但是现在我移动了它,我似乎无法弄清楚如何让它看到来自aspx表格的

控件一个共享班级坐在

app_code文件夹中?


比如说我的功能是:


public分享MarkScheduleLength()


dim i as integer

dim s as string


i = ctype(txtLength.Text ,整数)''它抱怨txtLength.Text

未被声明

s = cmbName.SelectedValue''它抱怨cmbName不是

宣布


........


我不想创建表单实例,因为我正在尝试到那时
捕获那个控件的确切值(当它改变时)而不是

用新值创建它的新实例,我试图捕获

cmbName_SelectedIndexChanges(....)每次用户更改掉落下来

菜单选择


我该如何解决这个问题?我有很多功能和方法可以访问文本框,下拉菜单,标签......等等,因为它们的值在
运行时更改,现在我被卡住了,它看不到他们中的任何一个。


微软禁用控件访问因为这个移动到App_Code

文件夹?他们没有想到这个?


请让我知道

谢谢

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

推荐答案

你的页面shoudl实现了一个接口,然后appcode可以将

当前页面转换为接口并访问表单字段。或类似于

版本1 appcode是一个基页(定义字段)和

你的页面继承它


- bruce(sqlwork.com)


netasp写道:
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:

嗨伙计们,

我遇到以下问题:

我正在尝试访问某些文本框&从我的函数下拉控件

位于app_code文件夹但我看不到它们,它抱怨没有

被声明!或者没有找到。


它在迁移之前在VS 2003中工作;因为没有App_Code

但是现在我移动了它,我似乎无法弄清楚如何让它看到来自aspx表格的

控件一个共享班级坐在

app_code文件夹中?


比如说我的功能是:


public分享MarkScheduleLength()


dim i as integer

dim s as string


i = ctype(txtLength.Text ,整数)''它抱怨txtLength.Text

未被声明

s = cmbName.SelectedValue''它抱怨cmbName不是

宣布


.......


我不想创建表单的实例,因为我正在尝试

捕获当时该控件的确切值(当它发生变化时)而不是

用新值创建它的新实例,我试图捕获<每次用户更改dro时,
cmbName_SelectedIndexChanges(....) p down

菜单选择


我该如何解决这个问题?我有很多功能和方法可以访问文本框,下拉菜单,标签......等等,因为它们的值在
运行时更改,现在我被卡住了,它看不到他们中的任何一个。


微软禁用控件访问因为这个移动到App_Code

文件夹?他们没想到这个?


请让我知道

谢谢

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


您好netasp,


您能否告诉我有关代码是如何在ASP.NET 1.1中编写的更多信息?

这种方式我可以提供更详细的建议,说明如何将它们成功迁移到ASP.NET 2.0。谢谢。

此致,

Walter Wang(wa****@online.microsoft.com,删除''在线''')

Microsoft在线社区支持


================================= =================

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。如果您使用的是Outlook Express,请确保清除

复选框工具/选项/读取:一次获取300个标题及时看到你的回复




注意:MSDN托管新闻组支持服务是针对非紧急问题

其中来自社区或Microsoft支持的初步响应

工程师可在1个工作日内完成。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========


此帖子按原样提供。没有保证,也没有授予任何权利。

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.


感谢Walter的回复,


添加新的在VS 2003中的Web表单,通常查看后面的代码

该表单将允许您编写任何方法或函数并引用任何web

控件放在表单上而没有任何问题例如,编写一个从文本框中获取字符串值的

函数就像说:

dim str as string = me.TextBox1.Text


但是使用visual studio 2005我不能这么简单,因为

的表格放在app_code文件夹中,它不会看到非

控制网页表格,所以说:

dim str as string = me.TextBox1.Text不起作用,它抱怨

TextBox1未定义。更多细节,我有一个函数在Visual Studio 2003中工作,在sql server 2005中调用存储过程,这个

函数传递一个变量(3个变量)来自表单上有3个文本框。

每次用户更改这些文本框中的一个

的值时,我都会调用此函数。


现在自迁移以来,visual studio 2005将所有类放在Ap_Code

文件夹下(作为他们的新功能之一!!)在

App_Code文件夹下移动我的功能阻止我调用/获取那些

文本框的值,因为它们改变了原因?因为班级看不到那些控件

坐在表格上!


感谢您的帮助。

" Walter Wang [MSFT]" < wa **** @ online.microsoft.com写信息

新闻:1t ************** @ TK2MSFTNGHUB02.phx.gbl ...
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...

您好netasp,


您能否告诉我有关代码如何在ASP.NET中编写的更多信息

1.1?

通过这种方式,我可以提供更详细的建议,说明如何将它们成功迁移到ASP.NET 2.0。谢谢。


此致,

Walter Wang(wa****@online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


============================= =====================

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。如果您使用的是Outlook Express,请确保清除

复选框工具/选项/读取:一次获取300个标题看到你的

回复

及时。


注意:MSDN管理新闻组支持服务是针对非紧急问题的/>
,可以在1个工作日内收到社区或Microsoft支持工程师的初步回复。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========


此帖子按原样提供。没有保证,也没有赋予

权利。
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.



这篇关于页面/控件ASP.NET 2.0中的继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆