我的Contentplaceholder问题 [英] My Contentplaceholder issue

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

问题描述

亲爱的伙计们,

这几天我真的很沮丧.我对asp.net和c#有点陌生,因为我的代码在后面.我希望有人能帮助我.

我创建了一个母版页.该页面本身分别包含两个不同的菜单项. 1是主菜单(< asp:菜单ID:mainmenu>),第二是边菜单(< asp:sidemenu id:sidemenu>).我也有contentplaceholder(< asp:ContentPlaceHolder ID = MainContent>).我的菜单项是动态的,因为数据是从表中提取的.第一次运行时(ispostback = false),所有内容都放置在适当的位置,没有问题.侧菜单中的数据取决于我主菜单的内容.它们中的大多数通过背后的代码进行编码.
我的菜单层次结构如下:
部门
-部门1(dept1.aspx)
-部门2(dept2.aspx)
产品
-书籍(books.aspx)
-手表(watches.aspx)
-笔(pens.aspx)
服务
-服务(services.aspx)

现在是问题所在:
当我单击第二个选项主菜单(包含产品)时,它将列出所有产品.当我单击侧面菜单中的任何产品(例如手表)时,它将特定的内容页面调用到主contentplaceholder(watches.aspx).问题是,在将所有内容加载到contentplaceholder中之后,ispostback将再次切换为false,并且我的menuitem中的所有数据也都为空,就好像我第一次在运行它一样.因此,它将像我第一次加载页面一样再次重置所有内容.因此,基本上,菜单项中的所有数据都将被重置.
我已经为此奋斗了好几个星期.

我非常感谢您的帮助和建议,以解决我的问题.我希望我的解释清楚.还请告诉我我的编程方法是否错误,什么是最好的解决方案.

非常感谢你.

吉姆.

Dear Guys,

I am really frustrated these few days. I''m kinda new to asp.net and c# as my code behind. i wish somebody could help me.

I am created a Masterpage. The page itself contains two different menu items separately. 1 is Main Menu (<asp:menuitem id:mainmenu>) and the 2nd is Side Menu (<asp:sidemenu id:sidemenu>). I also have contentplaceholder (<asp:ContentPlaceHolder ID=MainContent>). My menu items are dynamic since datas are pulled from a table. At first run (ispostback=false), all contents are in place with no problem. Datas in side menu are dependent to the content of my main menu. most of them are coded thru the code behind.
Hierarchy of my menu goes like this:
Department
- Department 1 (dept1.aspx)
- Department 2 (dept2.aspx)
Products
- Books (books.aspx)
- Watches (watches.aspx)
- Pens (pens.aspx)
Services
- Services (services.aspx)

Here''s the problem now:
When i click the 2nd option main menu (which contains products), it will enlist all products. When i click any products in my side menu (example watches), it calls an specific contentpage to a main contentplaceholder (watches.aspx). the problem is, after loading all the contents in the contentplaceholder, the ispostback will switch to false again and all my datas in my menuitem are also empty as if i''m running it again at the first time. so, it will reset all again as if i am loading the page like first time. so, basically, all of the datas in menu items will be resetted.
i am struggling on this for weeks now.

i really appreciate your help and advices as a solution to my problem. i wish my explanation are clear. Please tell me also if the approach of my programming is wrong and what is the best solution for it.

Thank you very much.

Jim.

推荐答案

您的enableviewstate是true吗?
Is your enableviewstate is true?


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

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