动态控制 - 回发后消失 [英] dynamic controls - disapear after postback

查看:58
本文介绍了动态控制 - 回发后消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态创建了几个网格,并将它们添加到vb.net Web表单上的不同

HTML占位符中。当网页首次启动时,它们内部的网格和控件

出现并且看得很漂亮,但是当我点击按钮,然后页面返回时,我的动态创建网格和

控件不可见。有什么想法吗?请查看下面的示例代码。


如果不是ispostback那么

creategrids

结束如果


Sub CreateGrids

''上面有很多代码

phInsulation.Controls.Add(MatrixInsul)''phinsulation是占位符

和MatrixInsul是我的网格

phGC.Controls.Add(MatrixGC)

phSM.Controls.Add(MatrixSM)

phControls.Controls.Add (MatrixControls)

phInsulation.EnableViewState = True

phGC.EnableViewState = True

phSM.EnableViewState = True

phControls.EnableViewState = True


结束子


提前感谢您的帮助!

Chris Thunell
ct******@pierceassociates.com

I have created several grids dynamically and have added them to different
HTML placeholders on a vb.net web form. The grids and controls within them
come up and view beautifully when the web page first starts, but when I
click on a button, and the page comes back, my dynamically created grid and
controls are not visible. Any thoughts? Please view my sample code below.

If Not ispostback then
creategrids
end if

Sub CreateGrids
''lots of code above
phInsulation.Controls.Add(MatrixInsul) ''phinsulation is a placeholder
and MatrixInsul is my grid
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM)
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

Thanks in advance for your help!
Chris Thunell
ct******@pierceassociates.com

推荐答案

因为回发表单时没有生成控件(例如,当你点击按钮时,你会发现CreateGrid函数不会产生
因此表格

将在没有控件的情况下呈现)


Chris Thunell <克拉****** @ pierceassociates.com>在消息中写道

新闻:eq **************** @ TK2MSFTNGP10.phx.gbl ...
Because the controls are not generated when you postback the form (e.g when
you click the button the CreateGrid function will not fire thus the form
will render without the controls)

"Chris Thunell" <ct******@pierceassociates.com> wrote in message
news:eq****************@TK2MSFTNGP10.phx.gbl...
我创建了动态的几个网格,并将它们添加到vb.net Web表单上的不同HTML占位符。当网页首次启动时,
内的网格和控件会出现,并且当我点击一个按钮,然后页面返回时,我动态创建网格
和控件不可见。有什么想法吗?请查看下面的示例代码

如果不是ispostback那么
creategrids
结束如果

Sub CreateGrids
''上面有很多代码
phInsulation.Controls.Add(MatrixInsul)''phinsulation是
占位符,MatrixInsul是我的网格
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM )
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

提前感谢您的帮助!
Chris Thunell
ct ****** @ pierceassociates.com
I have created several grids dynamically and have added them to different
HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page first starts, but when I
click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? Please view my sample code below.
If Not ispostback then
creategrids
end if

Sub CreateGrids
''lots of code above
phInsulation.Controls.Add(MatrixInsul) ''phinsulation is a placeholder and MatrixInsul is my grid
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM)
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

Thanks in advance for your help!
Chris Thunell
ct******@pierceassociates.com



是 - 您需要每次调用creategrids页面加载的时间 - 不仅仅是第一次

。动态创建的控件不会自动为你重新创建。


" Chris Thunell" <克拉****** @ pierceassociates.com>在消息中写道

新闻:eq **************** @ TK2MSFTNGP10.phx.gbl ...
Yes - you need to call creategrids every time the page loads - not just the
first time. Dynamically created controls are not going to automatically be
recreated for you.

"Chris Thunell" <ct******@pierceassociates.com> wrote in message
news:eq****************@TK2MSFTNGP10.phx.gbl...
我创建了动态的几个网格,并将它们添加到vb.net Web表单上的不同HTML占位符。当网页首次启动时,
内的网格和控件会出现,并且当我点击一个按钮,然后页面返回时,我动态创建网格
和控件不可见。有什么想法吗?请查看下面的示例代码

如果不是ispostback那么
creategrids
结束如果

Sub CreateGrids
''上面有很多代码
phInsulation.Controls.Add(MatrixInsul)''phinsulation是
占位符,MatrixInsul是我的网格
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM )
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

提前感谢您的帮助!
Chris Thunell
ct ****** @ pierceassociates.com
I have created several grids dynamically and have added them to different
HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page first starts, but when I
click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? Please view my sample code below.
If Not ispostback then
creategrids
end if

Sub CreateGrids
''lots of code above
phInsulation.Controls.Add(MatrixInsul) ''phinsulation is a placeholder and MatrixInsul is my grid
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM)
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

Thanks in advance for your help!
Chris Thunell
ct******@pierceassociates.com



这很简单。它们是第一次生成,但在回发期间

你没有调用CreateGrids函数,因为你告诉它不要用

if if ispostback statement因此,他们不会在随后的电话中创建

。你需要确定在回发期间需要什么不需要b $ b的玩具。可能是在某些按钮点击事件中

你想要在CreateGrids sub中添加一个调用,而在其他人中你不会。


希望这会有所帮助,

Mark Fitzpatrick

Microsoft MVP - FrontPage


" Chris Thunell" <克拉****** @ pierceassociates.com>在消息中写道

新闻:eq **************** @ TK2MSFTNGP10.phx.gbl ...
It''s pretty simple. They''re generated the first time, but during postback
you are not calling the CreateGrids function as you''ve told it not to with
the if not ispostback statement, thus they aren''t getting created on
subsequent calls. You need to toy with the determination of what isn''t
required during a postback. It could be that in certain button click events
you''ll want to add a call to the CreateGrids sub while in others you won''t.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Chris Thunell" <ct******@pierceassociates.com> wrote in message
news:eq****************@TK2MSFTNGP10.phx.gbl...
我创建了动态的几个网格,并将它们添加到vb.net Web表单上的不同HTML占位符。当网页首次启动时,
内的网格和控件会出现,并且当我点击一个按钮,然后页面返回时,我动态创建网格
和控件不可见。有什么想法吗?请查看下面的示例代码

如果不是ispostback那么
creategrids
结束如果

Sub CreateGrids
''上面有很多代码
phInsulation.Controls.Add(MatrixInsul)''phinsulation是
占位符,MatrixInsul是我的网格
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM )
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

提前感谢您的帮助!
Chris Thunell
ct ****** @ pierceassociates.com
I have created several grids dynamically and have added them to different
HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page first starts, but when I
click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? Please view my sample code below.
If Not ispostback then
creategrids
end if

Sub CreateGrids
''lots of code above
phInsulation.Controls.Add(MatrixInsul) ''phinsulation is a placeholder and MatrixInsul is my grid
phGC.Controls.Add(MatrixGC)
phSM.Controls.Add(MatrixSM)
phControls.Controls.Add(MatrixControls)
phInsulation.EnableViewState = True
phGC.EnableViewState = True
phSM.EnableViewState = True
phControls.EnableViewState = True

End Sub

Thanks in advance for your help!
Chris Thunell
ct******@pierceassociates.com



这篇关于动态控制 - 回发后消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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