帮助Web用户控制 [英] Help with web user control

查看:54
本文介绍了帮助Web用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个小型Web应用程序 - 我开始将所有代码放在

一个文件(config.aspx)中。正如我继续添加代码虽然它变得非常笨拙。


在线搜索后我找到了一篇文章,建议我可能

将一些代码放入Web用户控件中。我创建了两个新文件

(general_info.ascx和store_front.ascx)并在每个
中放置了两个代码块。


然后我在config.aspx顶部注册了控件:

<%@ Register TagPrefix =" UU"标签名= QUOT; general_info" Src ="〜/ general_info.ascx"

%>

<%@ Register TagPrefix =" UU"标签名= QUOT; store_front" Src ="〜/ store_front.ascx"

%>


我还将控件添加到config.aspx:

< UU:general_info id =" general_info1" RUNAT = QUOT;服务器" />

< UU:store_front id =" store_front1" RUNAT = QUOT;服务器" />


但是我收到以下错误:

元素''general_info''不是已知元素。如果网站中存在

编译错误,则会发生这种情况。


元素''store_front''不是已知元素。如果网站上有一个

编译错误,就会发生这种情况。


我似乎无法弄清楚我哪里出错了。我有点新的

csharp / asp.net所以我确定我只是做了一些愚蠢的错误。可以

有人指出我正确的方向吗?


谢谢你,

布拉德贝克

解决方案

3月11日下午5:17,Brad Baker < b ... @nospam.nospamwrote:


我正在构建一个小型Web应用程序 - 我开始将所有代码放在

一个文件(config.aspx)。正如我继续添加代码虽然它变得非常笨拙。


在线搜索后我找到了一篇文章,建议我可能

将一些代码放入Web用户控件中。我创建了两个新文件

(general_info.ascx和store_front.ascx)并在每个
中放置了两个代码块。


然后我在config.aspx顶部注册了控件:

<%@ Register TagPrefix =" UU"标签名= QUOT; general_info" Src ="〜/ general_info.ascx"

%>

<%@ Register TagPrefix =" UU"标签名= QUOT; store_front" Src ="〜/ store_front.ascx"

%>


我还将控件添加到config.aspx:

< UU:general_info id =" general_info1" RUNAT = QUOT;服务器" />

< UU:store_front id =" store_front1" RUNAT = QUOT;服务器" />


但是我收到以下错误:

元素''general_info''不是已知元素。如果网站中存在

编译错误,则会发生这种情况。


元素''store_front''不是已知元素。如果网站上有一个

编译错误,就会发生这种情况。


我似乎无法弄清楚我哪里出错了。我有点新的

csharp / asp.net所以我确定我只是做了一些愚蠢的错误。可以

有人指出我正确的方向吗?


谢谢你,

Brad Baker



汇编是否成功?


您在此处发布的代码看起来是正确的。


编译成功了吗? <


否 - 它产生我原帖中提到的错误(元素''XXX''是

不是已知元素....)


我发现了一条帖子,建议我需要将我的用户控件分组到

a文件夹 - 这似乎解决了原来的问题只是为了创建新的

错误。 :-)


现在我的问题似乎是在我的用户控件中引用仍然在config.aspx文件中的代码。从这里开始,我有点迷糊。我是

仍然在网上搜索并阅读一些参考书,但如果有人有任何想法我会很感激任何建议。 (以下是来自详细错误输出的几个

错误)


再次感谢,

Brad
< br $>
-----


webcontrols\general_info.ascx(48):错误BC30456:

''general_info_view_linkbutton_click''不是

''ASP.webcontrols_general_info_ascx''的成员。

AddHandler __ctrl.Click,AddressOf

Me.general_info_view_linkbutton_click

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ b $ b webcontrols\store_front.ascx(170):错误BC30456:

''store_front_edit_linkbutton_click''不是

''ASP.webcontrols_store_front_ascx''的成员。

AddHandler __ctrl.Click,AddressOf

Me.store_front_edit_linkbutton_click

~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~

webcontrols\store_front.ascx(179):错误BC30451:名称''convert_to_html''

未申报。

dataBin dingExpressionBuilderTarget.Text =

System.Convert.ToString(

convert_to_html(Convert.ToString(Eval(" additional_ domains"))),

System.Globalization.CultureInfo.CurrentCulture)


-----


" Alexey Smirnov" < al ************ @ gmail.comwrote in message

news:11 ****************** ***@8g2000cwh.googlegroup s.com ...


3月11日下午5:17,Brad Baker < b ... @nospam.nospamwrote:


>我正在构建一个小型Web应用程序 - 我开始放置所有代码
在一个文件(config.aspx)中。我继续添加代码虽然它变得非常笨拙。

在网上搜索后我找到了一篇文章,建议我
可能放置一些代码到Web用户控件。我创建了两个新文件
(general_info.ascx和store_front.ascx)并在每个文件中放置了两个代码块。

然后我在配置顶部注册了控件。 aspx:
<%@ Register TagPrefix =" UU" TagName =" general_info"
Src ="〜/ general_info.ascx"
%>
<%@ Register TagPrefix =" UU" TagName =" store_front"
Src ="〜/ store_front.ascx"
%>

我还将控件添加到config.aspx:
< UU:general_info id =" general_info1" RUNAT = QUOT;服务器" />
< UU:store_front id =" store_front1" RUNAT = QUOT;服务器" />

但是我收到了以下错误:
元素''general_info''不是已知元素。如果网站中存在编译错误,就会发生这种情况。

元素''store_front''不是已知元素。如果网站上有编译错误,就会发生这种情况。

我似乎无法弄清楚我哪里出错了。我在
csharp / asp.net有点新鲜所以我确定我只是在做一些愚蠢的错误。可以
任何人指出我正确的方向吗?

谢谢你,
Brad Baker



编译是否成功?


你在这里发布的代码看起来是正确的。





" Brad Baker" < br ** @ nospam.nospamwrote in message

news:ew ************** @ TK2MSFTNGP04.phx.gbl ...
< blockquote class =post_quotes>


>编译成功了吗? <



3月11日,晚上10:56,Brad Baker < b ... @nospam.nospamwrote:


编译是否成功? <



否 - 它产生我原始帖子中提到的错误(元素''XXX''是

不是已知元素... 。)



那是在运行时我猜,但是好的,现在我看到了什么问题。


webcontrols\general_info.ascx(48):错误BC30456:

''general_info_view_linkbutton_click''不是

''的成员ASP.webcontrols_general_info_ascx''。

AddHandler __ctrl.Click,AddressOf

Me.general_info_view_linkbutton_click



这意味着你没有一个名为general_info_view_linkbutton_click的方法

in general_info.ascx.vb


要么用AddHandler ....删除该行,要么创建一个方法你提到了。


>

webcontrols\store_front.ascx(170):错误BC30456:

''store_ front_edit_linkbutton_click''不是

''ASP.webcontrols_store_front_ascx''的成员。

AddHandler __ctrl.Click,AddressOf

Me.store_front_edit_linkbutton_click



同样的问题。


webcontrols\store_front.ascx(179):错误BC30451:名称''convert_to_html''



未声明。

dataBindingExpressionBuilderTarget.Text =

系统。 Convert.ToString(

convert_to_html(Convert.ToString(Eval(" additional_ domains"))),

System.Globalization.CultureInfo.CurrentCulture)



同样的问题,无法找到名称为convert_to_html的函数


I''m building a small web application - I started out placing all my code in
one file (config.aspx). As I continue to add code though it was becoming
very unwieldy.

After doing some searching online I found an article which suggested I might
place some of the code into web user controls. I created two new files
(general_info.ascx and store_front.ascx) and placed two chunks of code in
each.

I then registered the controls at the top of config.aspx:
<%@ Register TagPrefix="UU" TagName="general_info" Src="~/general_info.ascx"
%>
<%@ Register TagPrefix="UU" TagName="store_front" Src="~/store_front.ascx"
%>

And I also add the controls to config.aspx:
<UU:general_info id="general_info1" runat="server" />
<UU:store_front id="store_front1" runat="server" />

However I''m getting the following errors:
Element ''general_info'' is not a known element. This can occur if there is a
compilation error in the Web site.

Element ''store_front'' is not a known element. This can occur if there is a
compilation error in the Web site.

I can''t seem to figure out where I went wrong. I''m a bit new at
csharp/asp.net so I''m sure I''m just doing something stupid wrong. Could
anyone point me in the right direction?

Thank You,
Brad Baker

解决方案

On Mar 11, 5:17 pm, "Brad Baker" <b...@nospam.nospamwrote:

I''m building a small web application - I started out placing all my code in
one file (config.aspx). As I continue to add code though it was becoming
very unwieldy.

After doing some searching online I found an article which suggested I might
place some of the code into web user controls. I created two new files
(general_info.ascx and store_front.ascx) and placed two chunks of code in
each.

I then registered the controls at the top of config.aspx:
<%@ Register TagPrefix="UU" TagName="general_info" Src="~/general_info.ascx"
%>
<%@ Register TagPrefix="UU" TagName="store_front" Src="~/store_front.ascx"
%>

And I also add the controls to config.aspx:
<UU:general_info id="general_info1" runat="server" />
<UU:store_front id="store_front1" runat="server" />

However I''m getting the following errors:
Element ''general_info'' is not a known element. This can occur if there is a
compilation error in the Web site.

Element ''store_front'' is not a known element. This can occur if there is a
compilation error in the Web site.

I can''t seem to figure out where I went wrong. I''m a bit new at
csharp/asp.net so I''m sure I''m just doing something stupid wrong. Could
anyone point me in the right direction?

Thank You,
Brad Baker

Was the compilation successful?

The code you''ve posted here looks correct.


Was the compilation successful? <

No - it produces the error mentioned in my original post (Element ''XXX'' is
not a known element....)

I found a post which suggested that I needed to group my user controls into
a folder - that seemed to resolve the original problem only to create new
errors. :-)

Now my problem seems to be references in my user controls to code still in
the config.aspx file. I''m a bit befuddled as to where to go from here. I''m
still searching the net and reading a few reference books but if anyone has
any ideas I would appreciate any suggestions. (Below are a couple of the
errors from detailed error output)

Thanks Again,
Brad

-----

webcontrols\general_info.ascx(48) : error BC30456:
''general_info_view_linkbutton_click'' is not a member of
''ASP.webcontrols_general_info_ascx''.
AddHandler __ctrl.Click, AddressOf
Me.general_info_view_linkbutton_click
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

webcontrols\store_front.ascx(170) : error BC30456:
''store_front_edit_linkbutton_click'' is not a member of
''ASP.webcontrols_store_front_ascx''.
AddHandler __ctrl.Click, AddressOf
Me.store_front_edit_linkbutton_click
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

webcontrols\store_front.ascx(179) : error BC30451: Name ''convert_to_html'' is
not declared.
dataBindingExpressionBuilderTarget.Text =
System.Convert.ToString(
convert_to_html(Convert.ToString(Eval("additional_ domains"))) ,
System.Globalization.CultureInfo.CurrentCulture)

-----

"Alexey Smirnov" <al************@gmail.comwrote in message
news:11*********************@8g2000cwh.googlegroup s.com...

On Mar 11, 5:17 pm, "Brad Baker" <b...@nospam.nospamwrote:

>I''m building a small web application - I started out placing all my code
in
one file (config.aspx). As I continue to add code though it was becoming
very unwieldy.

After doing some searching online I found an article which suggested I
might
place some of the code into web user controls. I created two new files
(general_info.ascx and store_front.ascx) and placed two chunks of code in
each.

I then registered the controls at the top of config.aspx:
<%@ Register TagPrefix="UU" TagName="general_info"
Src="~/general_info.ascx"
%>
<%@ Register TagPrefix="UU" TagName="store_front"
Src="~/store_front.ascx"
%>

And I also add the controls to config.aspx:
<UU:general_info id="general_info1" runat="server" />
<UU:store_front id="store_front1" runat="server" />

However I''m getting the following errors:
Element ''general_info'' is not a known element. This can occur if there is
a
compilation error in the Web site.

Element ''store_front'' is not a known element. This can occur if there is
a
compilation error in the Web site.

I can''t seem to figure out where I went wrong. I''m a bit new at
csharp/asp.net so I''m sure I''m just doing something stupid wrong. Could
anyone point me in the right direction?

Thank You,
Brad Baker


Was the compilation successful?

The code you''ve posted here looks correct.




"Brad Baker" <br**@nospam.nospamwrote in message
news:ew**************@TK2MSFTNGP04.phx.gbl...

>Was the compilation successful? <

On Mar 11, 10:56 pm, "Brad Baker" <b...@nospam.nospamwrote:

Was the compilation successful? <


No - it produces the error mentioned in my original post (Element ''XXX'' is
not a known element....)

Well that was at run-time I guess, but ok, now I see what is the problem.

webcontrols\general_info.ascx(48) : error BC30456:
''general_info_view_linkbutton_click'' is not a member of
''ASP.webcontrols_general_info_ascx''.
AddHandler __ctrl.Click, AddressOf
Me.general_info_view_linkbutton_click

It means you don''t have a method called general_info_view_linkbutton_click
in general_info.ascx.vb

Either remove the line with AddHandler...., or create a method you refered.

>
webcontrols\store_front.ascx(170) : error BC30456:
''store_front_edit_linkbutton_click'' is not a member of
''ASP.webcontrols_store_front_ascx''.
AddHandler __ctrl.Click, AddressOf
Me.store_front_edit_linkbutton_click

The same problem.

webcontrols\store_front.ascx(179) : error BC30451: Name ''convert_to_html''
is
not declared.
dataBindingExpressionBuilderTarget.Text =
System.Convert.ToString(
convert_to_html(Convert.ToString(Eval("additional_ domains"))) ,
System.Globalization.CultureInfo.CurrentCulture)

The same problem, a function with name convert_to_html cannot be found


这篇关于帮助Web用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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