由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
DotNet版 - Answer Re: ASP.NET 难题测试 (1)
相关主题
ASP.NET 难题测试 (1)WebBrowser Control问题
问个MVC3的问题dynamic change before refreshing
请推荐一本 .net web site 的入门书default !
When do you want to use a Repeater control?a question about windows control
一个dropdownlist的问题datagrid help
User control question:怎么样才能让control随window的大小变化而变化?
A question about MVC问一个paste as html得 control
control array in .netCustomize Asp.net login control
相关话题的讨论汇总
话题: control话题: page话题: init
进入DotNet版参与讨论
1 (共1页)
p*p
发帖数: 75
1
你说得没错。
具体地说,是DropDownList 的 TrackViewState() 在第一个"before" item假如前还没有
被执行。
Page_Init
TrackViewState() called, 但这时候这个DropDownList还不存在。
Page_Load
ddlDynamic = new DropDownList()
ddlDynamic.Items.Add("before") - ddlDynamic的TrackViewState() not
called, 所以这时候加入的item没有被保存在ViewState里,postback后就丢失了
form1.Controls.Add(ddlDynamic); - 当一个Control加入到一个control hierachy
tree时,它的父节点会对他初始化,让这个Control及其子节点到达父节点的状态。因为
这时Page已经inited, 所以,Control_Init会执行,Control_TrackViewState() called.
ddlDyna
b*e
发帖数: 3845
2
Wow, really ASP.NET guru. Thanks for sharing this question.
By the way, do you know if there are any good books about ASP.NET
component (user control/custom control) design?

【在 p*p 的大作中提到】
: 你说得没错。
: 具体地说,是DropDownList 的 TrackViewState() 在第一个"before" item假如前还没有
: 被执行。
: Page_Init
: TrackViewState() called, 但这时候这个DropDownList还不存在。
: Page_Load
: ddlDynamic = new DropDownList()
: ddlDynamic.Items.Add("before") - ddlDynamic的TrackViewState() not
: called, 所以这时候加入的item没有被保存在ViewState里,postback后就丢失了
: form1.Controls.Add(ddlDynamic); - 当一个Control加入到一个control hierachy

p*p
发帖数: 75
3
Microsoft Press has a book: Developing Microsoft ASP.NET Server Controls and
Components. It's the best book about ASP.NET that I have ever see. Strongly
recommend.
Besides, the ASP.NET source code helps a lot on understanding how ASP.NET
works. You can use Reflector to see decompiled-code, or download the Mono
project source code. The Mono source code looks exactly the same as the
decompiled MS implementation. :)


没有
hierachy
因为
called.
上一
DropdownList

【在 b*e 的大作中提到】
: Wow, really ASP.NET guru. Thanks for sharing this question.
: By the way, do you know if there are any good books about ASP.NET
: component (user control/custom control) design?

n*********g
发帖数: 75
4

do it in Page_Init is a better choice?
I met the similar problem before but I didn't figure out the detail.
I solved the problem by move the code to Page_Init.

【在 p*p 的大作中提到】
: 你说得没错。
: 具体地说,是DropDownList 的 TrackViewState() 在第一个"before" item假如前还没有
: 被执行。
: Page_Init
: TrackViewState() called, 但这时候这个DropDownList还不存在。
: Page_Load
: ddlDynamic = new DropDownList()
: ddlDynamic.Items.Add("before") - ddlDynamic的TrackViewState() not
: called, 所以这时候加入的item没有被保存在ViewState里,postback后就丢失了
: form1.Controls.Add(ddlDynamic); - 当一个Control加入到一个control hierachy

k****i
发帖数: 1072
5
exactly.
We might need not to know the implementation detail of asp.net but we
definitely need to know the event sequence which is well documented.

没有
hierachy
因为
called.
上一
DropdownList

【在 n*********g 的大作中提到】
:
: do it in Page_Init is a better choice?
: I met the similar problem before but I didn't figure out the detail.
: I solved the problem by move the code to Page_Init.

k****i
发帖数: 1072
6

similar one would be Building ASP.NET Server Controls




【在 p*p 的大作中提到】
: Microsoft Press has a book: Developing Microsoft ASP.NET Server Controls and
: Components. It's the best book about ASP.NET that I have ever see. Strongly
: recommend.
: Besides, the ASP.NET source code helps a lot on understanding how ASP.NET
: works. You can use Reflector to see decompiled-code, or download the Mono
: project source code. The Mono source code looks exactly the same as the
: decompiled MS implementation. :)
:
:
: 没有

p*p
发帖数: 75
7
No, it won't help if the code is moved into Page_Init(), for the same reason:
when adding the "Before" item, the dropdownlist_TrackViewState is not called.
so, any state change will not be saved untill dropdownlist is added.
I read a MSDN article in which claims that the dynamically created controls
must be added at the Page_Init() stage, in fact, that's not correct .
Page_Init() is not the only time that the control will be initialized. When
new control is added at run time, the parent control

【在 n*********g 的大作中提到】
:
: do it in Page_Init is a better choice?
: I met the similar problem before but I didn't figure out the detail.
: I solved the problem by move the code to Page_Init.

1 (共1页)
进入DotNet版参与讨论
相关主题
Customize Asp.net login control一个dropdownlist的问题
.net 1.1 支持AJAX control toolkit 吗?User control question:
[合集] webbrowser control questionA question about MVC
Any good control to composite images in C#?control array in .net
ASP.NET 难题测试 (1)WebBrowser Control问题
问个MVC3的问题dynamic change before refreshing
请推荐一本 .net web site 的入门书default !
When do you want to use a Repeater control?a question about windows control
相关话题的讨论汇总
话题: control话题: page话题: init