调用从页面加载VB code一个JS [英] Calling a JS from VB code on pageload

查看:158
本文介绍了调用从页面加载VB code一个JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个asp.net项目中,数据库是通过VB code.Upon成功请求调用,在div必须animatee通过jQuery离开了。

I am working on an asp.net project in which database is being called through VB code.Upon successful request, the div must be animatee left via JQuery.

如:

VB code:

    If Confirmationcode = Passcode.text Then
        'Perform the animation here   ...   NextPage();
        'Registerstartupscript doesnt work as this is not in the page_load event
         Response.Redirect("Default.aspx", False)
    End If

JS:

    <script type="text/javascript">
    function NextPage() {
        $('.Wrapper').animate({ left: '-150%' }, 800);
    };
    </script>

有这么简单:

动画必须执行,而且一旦完成,则新的aspx页面必须重新装入。

The animation must be performed, and once completed, then the new aspx page must then load.

推荐答案

所以基本上你不应该使用的Response.Redirect 对于这种情况,你要首先执行的jQuery然后只页面应该重定向。

So basically you should not use Response.Redirect for this situation as you want to first execute the jQuery and then only the page should redirect.

尝试是这样的:

VB code:

If Confirmationcode = Passcode.text Then
    'Perform the animation here   ...   NextPage();//don't do this
     int flagAnimate = true;//set one flag here instead which will tell us whether to  animate the div or not
    'Registerstartupscript doesnt work as this is not in the page_load event//not needed
     //Response.Redirect("Default.aspx", False) //no need to redirect from here
End If

JS:

<% if(flagAnimate == true){ %>
  <script type="text/javascript">
  //perform your animation here
    function NextPage() {
      $('.Wrapper').animate({ left: '-150%' }, 800);
    };  
    NextPage();//by calling this function
   //and then redirect the page by using the following code
   self.location.href='/Default.aspx'
  </script>
<% } %>

这篇关于调用从页面加载VB code一个JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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