回传的用途是... [英] what is the use of is postback...

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

问题描述

任何人都可以按照代码&向我解释在这段代码中,为什么我们要使用ispostback?它的实际用途是什么....


编码:



Can anyone explain me following code & in this code why we are using ispostback what is the actual use of it....


coding:



protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Session["priority"] = txtpriority.Text;
         if (Request.QueryString["ids"] != null)
         {
             string ids = Request.QueryString["ids"];
             Session["ID"] = ids.ToString();
             update(ids);
         }

推荐答案

Try
在ASP.NET中自动回发 [ http://delphi.about.com/library/weekly/aa051705a.htm [ ^ ]
Try
Auto postback in ASP.NET[^]
http://delphi.about.com/library/weekly/aa051705a.htm[^]


有一个请看下面的链接.

IsPostBack
http://msdn.microsoft.com /en-us/library/system.web.ui.page.ispostback(v=VS.100).aspx

ASP.NET会话
http://msdn.microsoft.com/en-us/library/ms178581.aspx

QueryString
http://msdn.microsoft.com/en-us/library/system. web.httprequest.querystring.aspx

第一次访问页面时, http://www.dotnetperls.com/querystring
Have a look at below links.

IsPostBack
http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback(v=VS.100).aspx

ASP.NET Session
http://msdn.microsoft.com/en-us/library/ms178581.aspx

QueryString
http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring.aspx

http://www.dotnetperls.com/querystring


加载isPostBack ="false",
因此在循环内部被调用.
when first time the page is load isPostBack="false" ,
So inside the loop is been called.
if (!Page.IsPostBack)
 {
    //code
 }




在页面中,我们有一些按钮,当单击按钮时,同一页面将重新加载.
现在ispostBack ="true"
因此不调用循环..
Here in your Code you are

1.将文本框"值分配给会话变量.
2.Request.QueryString ["ids"]不等于null意味着我们再次被分配给Session变量.
3.根据此ID更新.

不必对每个事件都执行以下操作.在加载页面时,它是恒定的.

因此,对于我们正在PostBack事件中使用这些代码.




In the Page we have Some Buttons,While clicking the Button the same page is reloading again.
now ispostBack="true"
so for the loop is not called..
Here in your Code you are

1.Assigning the Textbox value into Session Variable.
2.Request.QueryString["ids"] is not equal to null means we are again assign into Session Variable.
3.Updating based on this Id.

The Following operation need not be performed for every event.Its been Constant while the Page is Loaded.

So For We are Using these code inside the PostBack Event.


这篇关于回传的用途是...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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