Created
August 21, 2012 13:22
-
-
Save ryanmcdonough/3415335 to your computer and use it in GitHub Desktop.
Run JQuery from within VB.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function runJQueryCode(ByVal message As String) As Boolean | |
Dim requestSM As ScriptManager = ScriptManager.GetCurrent(Page) | |
If requestSM IsNot Nothing AndAlso requestSM.IsInAsyncPostBack Then | |
ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), Guid.NewGuid().ToString(), getjQueryCode(message), True) | |
Else | |
Page.ClientScript.RegisterClientScriptBlock(GetType(Page), Guid.NewGuid().ToString(), getjQueryCode(message), True) | |
End If | |
Return True | |
End Function | |
Private Function getjQueryCode(ByVal jsCodetoRun As String) As String | |
Dim sb As New StringBuilder() | |
sb.AppendLine("$(document).ready(function() {") | |
sb.AppendLine(jsCodetoRun) | |
sb.AppendLine(" });") | |
Return sb.ToString() | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment