vb.net 如何从 vb 代码隐藏 (asp) 调用 jquery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14723076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call a jquery from vb codebehind (asp)
提问by Ley47
I am new to jqueries and I have a problem calling a dialog box If ever my user has an invalid search query and did not put a starting date. See I have this jquery code
我是 jqueries 的新手,如果我的用户有无效的搜索查询并且没有输入开始日期,我在调用对话框时遇到问题。看到我有这个 jquery 代码
$(function(){
$("#dialog").dialog(function() {
$("#dialog").dialog()};
});
});
Now I have these codes in vb :
现在我在 vb 中有这些代码:
Sub Subsearch()
If txtfrom.Text <> "" And txtto.Text <> "" Then
//some codes
ElseIf txtfrom.Text <> "" And txtto.Text = Nothing Then
//some codes
ElseIf txtfrom.Text = Nothing And txtto.Text <> "" Then
//call my JQuery
Else
// some codes
End If
End Sub
Now how do I do this?
现在我该怎么做?
回答by coder
Try this:
尝试这个:
Update to VB.NET
更新到 VB.NET
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "blah", "myfunction();", True
If you're using a ScriptManager, use RegisterStartupScript(), use it this way:
如果您使用的是 ScriptManager,请使用 RegisterStartupScript(),以这种方式使用它:
ScriptManager.RegisterStartupScript(this, GetType(), "modalscript",
"$(function() { $('#dialog').dialog(); });", true);
回答by freaky
dim myjquery as string="$(function(){ $('#dialog').dialog(function() {$('#dialog').dialog()} ; }); });"
response.write(myjquery)
Let me know if it works or not
让我知道它是否有效
回答by SQLGuru
you could use the JQuery to validate your input boxes, thereby not having to use the VB code to do it...
您可以使用 JQuery 来验证您的输入框,从而不必使用 VB 代码来执行此操作...
http://docs.jquery.com/Plugins/Validation
http://docs.jquery.com/Plugins/Validation
http://speckyboy.com/2009/12/17/10-useful-jquery-form-validation-techniques-and-tutorials-2/
http://speckyboy.com/2009/12/17/10-useful-jquery-form-validation-techniques-and-tutorials-2/

