AjaxÓëSessionµÄÎÊÌâ - .NET¼¼Êõ / ASP.NET
֮ǰÓöµ½Ò»¸öÎÊÌâ¡£
ÓÚÊÇ×öÁËÒÔÏÂʵÑ飺
Ò³Ãæ¼ÓÔغó£¬Ìá½»Ò»¸öAjaxÇëÇó(ÔݳÆΪajax1)£¬ÇëÇóµÄÏß³ÌÔÚ·þÎñÆ÷Éϱ»Ë¯Ãß10ÃëÖÓ¡£
µã»÷Ò³ÃæÉÏÒ»¸öbutton£¬´¥·¢ÁíÒ»¸öAjaxÇëÇó(ajax2)¡£
µ±Ã»ÓÐʹÓÃsession£¬ÔÚ·þÎñÆ÷δ´¦ÀíÍêajax1µÄÇëÇóʱ£¬·þÎñÆ÷ÒÀÈ»¿ÉÒÔ´¦Àíajax2µÄÇëÇó¡£
µ«ÊÇ£¬µ±Ê¹ÓÃÁËsession£¬ÔÚ·þÎñÆ÷δ´¦ÀíÍêajax1µÄÇëÇóʱ£¬·þÎñÆ÷²»ÄÜ´¦Àíajax2µÄÇëÇó¡£±ØÐëµÈµ½ajax1´¦ÀíÍê³Éºó£¬²ÅÄÜ´¦Àíajax2µÄÇëÇó¡£
ʹÓÃsessionµÄ´úÂëºÜ¼òµ¥£¬Session.Add("user", "aaa");
Çó½ÌÅ£ÈË£¬ÈçºÎÔÚʹÓÃÁËsessionºó£¬µ±ajax1δ´¦ÀíÍê³Éʱ£¬ÒÀÈ»¿ÉÒÔ´¦Àíajax2µÄÇëÇó£¿
Õâ¸öÎÊÌ⣬ÈÃÎÒºÜÍ·´ó¡£
ajax²»ÊÇ·¢Ë͵ÄÒì²½ÇëÇóÂð£¿
Ϊʲô£¬Ê¹ÓÃÁËsessionºó£¬¾Í±ä³Éͬ²½µÄÁË£¿
Äã´úÂëÊÇÔõôдµÄ
ʵÏÖʲô¹¦ÄÜ£¬´úÂëÈçºÎ±àдµÄ.˳ÐòÖ´ÐоÍÊÇ
´úÂëÌù³öÀ´
http://www.zainanbao.com
ÎÒÏëµÄÊÇAjax1ºÍAjax2ÕâÁ½¸öÇëÇóÊDz»ÊǶ¼Óõ½ÁËsessionÄØÁË´úÂëÖУ¬ÒªÊǶ¼Óõ½ÁË£¬¿ÉÄÜsession²»ÔÊÐíͬʱ½øÐзÃÎÊ£¬ËùÒÔµ¼ÖÂÁËÄãÏÖÔÚµÄÇé¿ö¡£
..»¹Õæ²»ÖªµÀÓÐÕâÇé¿ö.
C# code:
protected void Page_Load(object sender, EventArgs e)
{
//ʹÓÃsessionµÄ´úÂë
Session.Add("user", "aaa");
switch (Request.QueryString["action"])
{
case "ajax1":
Thread.S
Ïà¹ØÎÊ´ð£º
aspÏÂÃ棬µ±Òª¸ù¾Ý²»Í¬µÄȨÏÞÏÔʾһЩ¹¦ÄÜ°´Å¥µÄ»°»áд³É
<%
if ȨÏÞ=1 then
%>
<input type="submit" name="Submit" value="Ìá½»" />
<%
end i ......
select top 12 * from Product where [id] not in (select top 12 [id] from Product)
ÕâÑù¿ÉÒÔ·ÖÒ³£¬µ«ÊÇÎÒÔÚºóÃæÏë¼Ó¸öÌõ¼þ
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......
ÎÒÔÚ Page_Load ÀïдÁË
if(!IsPostBack){
GridView1.DataSource=GroupManager.GetGroups();//GetGroups ·µ»ØµÄÊÇ IList<Group>
GridView1.DataBind();
}
¿ÉÎÒÔÚ Submit_Click Àïд´ú ......
ÎÒÓг§¼Ò×öµÄASPµÄ¼à¿Ø¼Ïñ£¨DVR£©µÄ¾ÖÓòÍø²¥·ÅµÄÔ´³ÌÐòÓë¿Ø¼þ£¬ÏëÒªÓÃASP.net×öÒ»¸öÊÓƵ»Ø·ÅµÄ³ÌÐò£¨ÀûÓÃËûµÄ¿Ø¼þ£©µ«²»ÖªÈçÏÂÈ¥×ö£¬Íû¸÷λָµã¡£
ÏȸãÇå³þËûÃǵĿؼþÊÇÔõôÓõÄ,
È»ºó¾ÍÖ±½ÓÓúÃÁË.
²»¹ý,Èç ......
ÔÚµ¯³ö¿òÖеã»÷Ò»¸ö°´Å¥£¬Ôõôµ÷תµ½ÁíÒ»¸öä¯ÀÀÆ÷£¬²¢ÇÒÔÚ¸Ãä¯ÀÀÆ÷´ò¿ªÁ½¸öÒ³Ãæ
ÄãµÄÒâ˼Ӧ¸ÃÊÇ
response.write("<script>alert('È·ÈÏ'); window.location.href('xxxx.aspx'); </script>"); ......