Master Pages,似乎比它修复了更多的问题? [英] Master Pages, seems like it causes more problems than it fixes?

查看:54
本文介绍了Master Pages,似乎比它修复了更多的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在开发一个开源项目,并且

决定在专注于

功能之后真正尝试让它看起来更好看时间。到目前为止,我只使用了一个

标准ASPX页面,并对其进行了少量修改。我的所有页面

都继承自BasePage.cs。 class,处理常见的事情,比如

从会话中获取用户的信息,确定页面

应该或不应该受密码保护等等。到现在为止它已经工作得很好了,但是如果它没有坏了......修好它吧?


因此我决定尝试合并我的Visual Web中的MasterPages

Developer Express,因为它看起来很简单,并且会给我更多

控制我的页面,并允许我减少额外的ASPX内容等。不幸的是,
错了。


简单地说,我的问题如下:

1)我需要摆脱 ctl001 $的contentPane $"我的表单中的前缀

集合键名。

2)我需要消除必须存在的冗余属性

在我的BasePage.cs中和MasterPage.cs访问登录信息等

来自会话。


更多细节如下:


1)我意识到的第一件事是当我尝试登录时,所有

Request.Form NameValueCollection中的密钥都有ctl001 $ content $

前缀。我为此修了一个解决方法只是为了看看是否有任何其他问题,但我宁愿没有我的表格

控制前面有这样的废话,只是让我的生活更加艰难。我的意思是,页面上只能存在一个服务器表单,为什么你需要指定它来自特定的内容窗格,为什么

ctl001总是存在如果它不应该改变?我的意思是,这是

需要再花5个小时来完成所有工作并再次测试如果我没有b $ b无法摆脱这个愚蠢的前缀,它最终会看起来非常好的/ b $ b screwey,我根本不需要它。


2)同样,我的BasePage.cs保存userinfo,登录状态等等

属性的值实际上是从会话中获得的

下面的。现在我的MasterPage.cs似乎无法访问这个信息,所以我必须在

基页类中添加相同的属性。 MasterPage类,以便他们可以以标准方式从会话中获取信息

。然后我可以让所有的

BasePages从它的主页属性中获取属性,或者

否则代码将是redundent。但是如果

没有我的基页的主页属性(IE,一个页面没有使用主页概念,那么
)会造成问题。所以我回到了两个地方重复的会话对象的相同属性

访问器。我真的在

亏本以解决这个问题的正确方法。我的意思是,我将在我的MasterPage.cs和BasePage.cs文件中使用

冗余代码,所有这些我都可以想到修复它。我可以做一些辅助类,实际上

从传入的会话中获取信息,但这似乎非常好b / b
cludgy,但至少是代码的真正内容不会重演。


请帮忙,我的意思是,这应该是难以使用

MasterPages?它是否真的是你必须使用它们的情况?

我该怎么做才能解决这个问题?

解决方案
的contentPane

"我的表单中的前缀

集合键名。

2)我需要消除必须存在的冗余属性

在我的BasePage.cs中和MasterPage.cs访问登录信息等

来自会话。


更多细节如下:


1)我意识到的第一件事是,当我尝试登录时,所有

Request.Form NameValueCollection中的键都有ctl001


content

So I have been working on an opensource project for a while, and
decided to really try to make it look better after focusing on the
functionality most of this time. Up to now, I have simply used a
standard ASPX page with minor modifications to it. All of my pages
inherit from a "BasePage.cs" class, that handles common things like
getting the user''s information out of the session, determines if a page
should or should not be password protected, etc. Up until now it has
all been working fine, but if it ain''t broke.. FIX IT right?

Thus I decided to attempt to incorporate MasterPages in my Visual Web
Developer Express since it seemed so easy and would give me much more
control over my pages and allow me to reduce extra ASPX content, etc...
wrong unfortunatly.

Briefly my problems are as follows:
1) I need to get rid of the "ctl001$contentPane$" prefix from my form
collection keynames.
2) I need to elliminate redundant properties that would have to exist
in both my BasePage.cs and MasterPage.cs that access login info, etc
from the session.

More detail follows:

1) The first thing I realized is that when I attempted to login, all of
the keys in the Request.Form NameValueCollection had "ctl001$content$"
prepended. I hacked a workaround for this just to see if there were
going to be any other problems, but I would rather NOT have my form
controls prepended with such nonsense, just makes my life more
difficult. I mean, only one server form can exist on a page, why do you
need to specify that it came from a specific content pane, and why is
ctl001 always there if it isn''t supposed to change? I mean, this is
going to take another 5 hours to get all working and tested again if I
cannot get rid of this stupid prefix, and it will end up looking VERY
screwey, and I don''t want that at all.

2) Again, my BasePage.cs holds userinfo, login status, etc as
properties who''s values are actually obtained from the session
underneath. Now it would seem that my MasterPage.cs doesn''t have access
to this information, so I would have to put the same properties in the
basepage class in the MasterPage class, so that they can get the info
from the session in a standard way. Then I could have all of the
BasePages actually get the properties from it''s masterpage property, or
the code would be redundent otherwise. But this would pose a problem if
there was NO masterpage property of my basepage (IE, a page that didn''t
use the masterpage concept). So I am back to having the same property
accessors of the session object repeated in two places. I am really at
a loss for the correct way to fix this. I mean, I am going to have
redundant code in my MasterPage.cs and BasePage.cs file all the ways I
can think of fixing it. I could make some helper class that actually
gets the info from the session that is passed in, but that seems VERY
cludgy, but at least the real guts of the code wouldn''t be repeated.

Help help please, I mean, is it supposed to be this difficult to use
MasterPages? Is it realy a situation where you have to use them or not?
What can I do to fix this??

解决方案

contentPane


" prefix from my form
collection keynames.
2) I need to elliminate redundant properties that would have to exist
in both my BasePage.cs and MasterPage.cs that access login info, etc
from the session.

More detail follows:

1) The first thing I realized is that when I attempted to login, all of
the keys in the Request.Form NameValueCollection had "ctl001


content


这篇关于Master Pages,似乎比它修复了更多的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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