我在正确的轨道上(ASPX,ASCX,设计) [英] Am I on the right track (ASPX, ascx, design)

查看:88
本文介绍了我在正确的轨道上(ASPX,ASCX,设计)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个网页,每个网页都或多或少是相同的。他们每个人都在顶部有一个员工的部分。下一节是客户部分,节后为previous订单。这两个是不是在所有页面绝对必要的。最后一节是评论(博客)。

I have several webpages, each of these pages are more or less the same. Each of them have a employee section at the top. Next section is the customer section, and section after is previous orders. These two are not strictly necessary on all pages. Last section is comments (blogging).

我开始了2页,没有问题。我写了相同的(复制粘贴)code为每个页面(给予或采取一对夫妇的详细信息)。销售给了(饵),这给客户和客户饿了...更多更多更多......现在我有10页或多或少相同code。

I started out with 2 pages, no problem. I wrote the same (copy-paste) code for each page (give or take a couple of details). Sales gave(baited) this to the customer and the customer got hungry .. more more MORE... Now I have 10 pages with more or less the same code.

现在我想我可以重复使用相同的控制缩短开发时间。于是开始做一些ASCX(4),想我可以重用这些4控制每个页面(员工,客户,销售,博客)。

Now I was thinking can I reduce dev time by reusing the same "controls". So started doing some ascx (4), thinking I could reuse these 4 controls with each page (employee, customer, sales, blog).

我碰到一个小抓举和谷歌告诉我 - 没有没有没有,是不是你如何使用ASCX。一个ASCX仅仅是一个新的 ASP:标签/ ASP:文本框有可能是一点点额外的逻辑

I run into a little snatch and google tells me - "no no no that is not how you use ascx". An ascx is merely a new "asp:label" / "asp:textbox" with perhaps a little extra logic in.

抢夺的生活 - 我做了一个NewTest.aspx每个在4控制的,但我没有看到 ASP:FormView控件 / ASP:DetailsView控件等从控制。我可以把你好世界一切围绕FormView控件,就在刚结束 - 但不是在< FormView控件>< / FormView的>

Snatch being - I made a NewTest.aspx with each of the 4 controls in, but I'm not seeing the asp:formview / asp:detailsview etc from the controls. I can put "hello worlds" all around the formview, just before, just after - but not inside the <formview></formview>.

我要去哪里错了,我需要重新考虑什么呢?

Where am I going wrong, what do I need to reconsider?

NewTest.aspx

NewTest.aspx

    <table width="800">
        <tr>
            <td>
                <IIT:EmployeeRecord ID="test1" runat="server" />
            </td>
        </tr>
     </table>

我使用的ObjectDataSource和会话拉雇员ID。雇员记录 - 他的名字,他的拉链codeS(仅SalesRep的)和一个搜索栏下拉。 Basicly一个文本框(ES)有一点点额外的逻辑。

I use ObjectDataSource and pull the employee ID from Session. The Employee record - His name, a dropdown with his zipcodes(salesrep only) and a search field. Basicly a textbox(es) with a little extra logic.

所有底层逻辑(血铅水平,达尔斯,模型等)是precisely相同。该项目的其余部分编译和运行pcisely $ P $和以前一样,我开始与ASCX的。

All the underlying logic (BLLs, DALs, Models, etc) are precisely the same. Rest of the project compiles and runs precisely the same as before I started with the ascx's.

编辑:我努力地KSS这一点,如果我能得到EmployeeRecord展现,那么我可以复制粘贴的想法。

I'm trying hard to KSS this, if I can get EmployeeRecord to show, then I can copy-paste that idea.

在开始webconfig:

Start in webconfig:

<pages>
<controls>
    <add tagPrefix="IIT" tagName="Comments" src="~/DynamicData/FieldTemplates/Comments.ascx" />
    <add tagPrefix="IIT" tagName="OrderRecord" src="~/DynamicData/FieldTemplates/OrderRecord.ascx" />
    <add tagPrefix="IIT" tagName="CustomerRecord" src="~/DynamicData/FieldTemplates/CustomerRecord.ascx" />
    <add tagPrefix="IIT" tagName="EmployeeRecord" src="~/DynamicData/FieldTemplates/EmployeeRecord.ascx" />
  </controls>
</pages>

智能感知可以识别EmployeeRecord和OrderRecord,但不评论和的CustomerRecord。 编辑:智能感知现在可以识别它们全部

EmployeeRecord

EmployeeRecord

<asp:formview ID="fv_empDetail" runat="server" datasourceID="ods_empDetail">
<itemtemplate>
<table>
    <tr>
        <td>
        Medarbejder:
        </td>
    <td>
<asp:TextBox ID="tbEmployeeName" runat="server" ReadOnly="true" Text='<%# Bind("name") %>' BorderStyle="None"></asp:TextBox>
</td></tr>
</table>
</ItemTemplate>
</asp:FormView>
    <asp:ObjectDataSource ID="ods_empDetail" runat="server" SelectMethod="GetEmployee"
     TypeName="xxxxxx.EmployeeBLL">
     <SelectParameters>
         <asp:SessionParameter Name="employee" DbType="String" SessionField="employee" />
     </SelectParameters>
 </asp:ObjectDataSource>

(任何错别字是为您的乐趣只),有在现实code无错别字)

(Any typos are for your pleasure only ;) , there are no typos in the real code)

推荐答案

使用母版为您的项目。如果你认为有对网页一些常见的特定组信息的其他群体irresective,然后使用嵌套母版页的网页的特定群体。

Use MasterPage for your project. If you think that there are information for some common specific group of pages irresective of other groups, then use a nested master page for those specific groups of pages.

使用嵌套masterpages将让你的根母版的光,将成为其他页面了。

Using nested masterpages will keep your root masterpage light, and will serve for other pages too.

您也可以按照链接,开发用户通过控制作为@Umar给予或参阅以下内容:

You can also follow the link for developing user control as given by @Umar or refer to the following:

创建ASP.NET用户控件

我的用户控制

这篇关于我在正确的轨道上(ASPX,ASCX,设计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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