且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Web用户控件不在asp.net中调用if(!ispostback)事件

更新时间:2023-12-06 09:58:28

您可能需要阅读文档。

You might want to read up on the documentation.
[BrowsableAttribute(false)]
public bool IsPostBack { get; }

Property Value
Type: System.Boolean
true if the page is being loaded in response to a client postback; otherwise, false.

以下示例显示如何测试的值加载页面时, IsPostBack 属性,以确定页面是第一次呈现还是响应回发。如果页面是第一次呈现,则代码调用 页面验证 方法。

The following example shows how to test the value of the IsPostBack property when the page is loaded in order to determine whether the page is being rendered for the first time or is responding to a postback. If the page is being rendered for the first time, the code calls the Page.Validate method.

页面标记(未显示)包含 RequiredFieldValidator 控制显示如果没有输入所需的输入字段,则为星号。致电 Page 验证 会导致在呈现页面时立即显示星号,而不是等到用户单击提交按钮。回发后,您不必调用 页面验证 ,因为该方法是作为 页面 生命周期。

The page markup (not shown) contains RequiredFieldValidator controls that display asterisks if no entry is made for a required input field. Calling Page.Validate causes the asterisks to be displayed immediately when the page is rendered, instead of waiting until the user clicks the Submit button. After a postback, you do not have to call Page.Validate, because that method is called as part of the Page life cycle.


谢谢大家,



实际上它的更新面板正在解决问题。



当我删除更新时面板,然后代码工作正常。
Thanks everyone,

Actually its update panel which is making the problem.

When I removed update panel, then the code is working fine.