从javascript和HTML调用后面的Aspx.vb代码 [英] Aspx.vb code behind calling from javascript and HTML

查看:123
本文介绍了从javascript和HTML调用后面的Aspx.vb代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从< a>调用aspx.vb页面标记工作正常并执行Sub page_load中的代码。 Sub Page_Load然后调用javascript。这也很好。



从javascript / jquery调用aspx.vb页面可以正常工作并执行Sub page_load中的代码。 Sub Page_Load然后调用javascript。然而,这不起作用。并且不会抛出错误。



我尝试了什么:



使用标签 -



Calling an aspx.vb page from an <a> tag works fine and executes the code in the Sub page_load. The Sub Page_Load then makes a call to javascript. This also works fine.

Calling an aspx.vb page from javascript/jquery works fine and executes the code in the Sub page_load. The Sub Page_Load then makes a call to javascript. This however does NOT work. And does not throw an error.

What I have tried:

Using the
tag -

<a> href='BufferDownLoad.aspx'>test</a>





调用aspx.vb Page_Load罚款。

在Sub Page_Load的aspx.vb中我调用javascript -



ScriptManager.RegisterStartupScript(Me,Me.GetType(),testCall,testCall();,True)



这个工作正常。



如果我使用javascript / jquery来调用.aspx.vb -



$ .get(BufferDownLoad.aspx)



Page_Load执行正常。但是调用javascript -



ScriptManager.RegisterStartupScript(Me,Me.GetType(),testCall,testCall();,True)



不起作用。并且它不会引发错误。



什么可能出现?

推荐答案

.get(BufferDownLoad.aspx)



Page_Load执行正常。但是调用javascript -



ScriptManager.RegisterStartupScript(Me,Me.GetType(),testCall,testCall();,True)



不起作用。并且它不会引发错误。



什么可能出现?
.get("BufferDownLoad.aspx")

The Page_Load executes fine. BUT the call to javascript -

ScriptManager.RegisterStartupScript(Me, Me.GetType(), "testCall", "testCall();", True)

Does NOT work. And it does not throw an error.

What could be up?


你的 Page_Load 方法不是调用Javascript代码。它正在注册要在页面加载时返回的HTML响应中呈现的脚本块。



当您点击页面链接时,整个浏览器文档将替换为页面返回的HTML。这包括在HTML中加载和执行脚本块



当您使用时jQuery.get()方法 [ ^ ]要请求页面,HTML将加载到变量中。返回的HTML中的任何脚本块都不会被执行。



如何解决这个问题取决于你想要对返回的HTML做什么。使用 UpdatePanel控件 [ ^ ]。
Your Page_Load method isn't "calling" Javascript code. It's registering a block of script to be rendered in the HTML response that will be returned when the page loads.

When you click on a link to the page, the entire browser document is replaced with the HTML returned by your page. This includes loading and executing script blocks within the HTML

When you use the jQuery.get() method[^] to request the page, the HTML is loaded into a variable. None of the script blocks within the returned HTML will be executed.

How you solve that depends on what you want to do with the returned HTML. You might have better luck using an UpdatePanel control[^] instead.


我认为不同这样做的方式。而不是服务器试图调用javascript,我有javascript调用服务器,让服务器做它的事情,并将结果中继回客户端。如果结果是肯定的,我让客户端调用javascript -



函数newList(){
I figured a different way of doing it. Instead of the server trying to call javascript, I had javascript call the server, have the server do it's thing and relay a result back to the client. If the result is positive, I have the client call the javascript -

function newList() {


这篇关于从javascript和HTML调用后面的Aspx.vb代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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