在C#中使用JavaScript [英] Use JavaScript inside C#
本文介绍了在C#中使用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ASP.NET正文网页中拥有此代码:
I have this inside my ASP.NET body webpage:
<script type="text/javascript" charset="utf-8">
var edited = function(note) {
alert("Edited note with id " + note.id + ", new text is: " + note.text);
}
var created = function(note) {
alert("Created note with id " + note.id + ", text is: " + note.text);
}
var deleted = function(note) {
alert("Deleted note with id " + note.id + ", text is: " + note.text);
}
var moved = function(note) {
alert("Moved note with id " + note.id + ", text is: " + note.text);
}
var resized = function(note) {
alert("Resized note with id " + note.id + ", text is: " + note.text);
}
jQuery(document).ready(function() {
var options = {
notes:[{"id":1,
"text":"Test Internet Explorer",
"pos_x": 50,
"pos_y": 50,
"width": 200,
"height": 200,
}]
,resizable: true
,controls: true
,editCallback: edited
,createCallback: created
,deleteCallback: deleted
,moveCallback: moved
,resizeCallback: resized
};
jQuery("#notes").stickyNotes(options);
});
</script>
如何将其从.cs更改为page_load函数?
How can I change it to the page_load function from .cs ?
推荐答案
hi,
<br />
Page.RegisterStartupScript("OnLoad","<script>functionName();</script>");
希望对您有所帮助.
Hope This may help you..
您可以在服务器端的页面加载中创建整个脚本,并使用ScriptManager对其进行注册.
You can create the entire script in pageload at server side and register it using ScriptManager
使用webrowser.Document. invokescipt(方法名称",args);
use webrowser.Document.invokescipt("name of methode", args);
这篇关于在C#中使用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文