从JavaScript调用一个VB.net功能 [英] calling a VB.net function from javascript
问题描述
我需要找到一种方法,从JavaScript调用vb.net函数在我的aspx页面。我有一个jQuery函数,使.drop类.droppable,每当我滴个.draggable到下降的目标,我的Jquery code成功地发射一个java警告声明。所有的纯JavaScript。我需要做的是一些沉重的数学!
我不明白,存在的JavaScript客户端,ASP / VB存在服务器端,从来没有,二人见面。从谷歌的研究,这似乎是一个理想的方式来得到什么,我需要做,是触发我的更新面板异步回发。我创建了一个隐藏的按钮被称为HiddenButton,我也创建了一个名为HiddenLabel隐藏的标签。我如何得到它的工作,所以当我掉了什么东西,我的JavaScript调用的东西,在HiddenLabel(这样我就可以将值传递给服务器端)更新包括文本,并以某种方式触发HiddenButton_click事件?
我目前的javascript善良看起来是这样的:
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
doReady();
变种PRM = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(功能(S,E){
doReady();
});
});
传播doReady(){
$('拖')拖动({回复:真,助手:克隆});
$('滴')。投掷的({
宽容:触摸,//这里应该是一个字符串
下降:函数(){警报('下降'); }
这就是我认为有些事情需要去更新标签和触发回发的,但我不知道它是什么:(
});
} //结束做准备
< / SCRIPT>
您可以使用隐藏变量的OnValueChanged事件。电线了该事件,改变隐变量的值,并写入这一说法 -
__ doPostBack('<%= hdnHidden.UniqueID%>',''); //此语句将触发OnValueChanged事件和控制将被转移到服务器端,您可以更新标签,做你的处理。
I need to find a way to call a vb.net function in my aspx page from javascript. I have a Jquery function that makes the .drop class .droppable, and whenever I drop a .draggable onto a drop target, my Jquery code successfully fires a java alert statement. All in pure javascript. What I need to do is some heavy math!
I do understand that javascript exists client-side, ASP/VB exists server-side, and never the two shall meet. From google research, it seems like the ideal way to get what I need done, is to trigger an asynchronous postback in my update panel. I created a hidden button called "HiddenButton", and I also created a hidden label called "HiddenLabel". How do I get it to work so when I drop something, my javascript calls something that updates both the text in the HiddenLabel (so I can pass a value to server-side), and somehow fire the HiddenButton_click event?
My current javascript goodness looks like this:
<script type="text/javascript">
$(document).ready(function() {
doReady();
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function(s, e) {
doReady();
});
});
function doReady() {
$('.drag').draggable({ revert: true, helper: 'clone' });
$('.drop').droppable({
tolerance: "touch", // Here should be a string
drop: function() { alert('dropped'); }
This is where I think something needs to go to update the label and trigger the post-back, but I don't know what it is :(
});
} // End of do ready
</script>
You can use the hidden variable's OnValueChanged event. Wire up that event, change the value of the hidden variable, and write this statement -
__doPostBack('<%= hdnHidden.UniqueID %>', ''); //This statement will fire the OnValueChanged event and the control will be moved to the server side where you can update the label and do your processing.
这篇关于从JavaScript调用一个VB.net功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!