【问题标题】:Dynamically add code to div element in VB code behind在VB代码后面动态添加代码到div元素
【发布时间】:2017-03-01 20:16:18
【问题描述】:

在我的 .aspx 页面中,我有一个 div 元素,其 id 为 mainGameBattle。

在后面的 .vb 代码中,我需要检查一个变量,如果满足条件,我需要使用 jQuery 将另一个 .aspx 页面动态加载到 div 中,如下所示:

.aspx

<div id="mainGameBattle" runat="server" style="border: none;"></div>

和背后的代码:

If String.IsNullOrEmpty(thisBattle.Group) Then

     //add dynamic jQuery load event to div element....
     //<script type='text/javascript'>
         //$('#mainGameBattle').load('http://mysamedomain.org/spaceArena.aspx?battleID=" & thisBattle.ID & "');"
     //</script> 

End If

有没有办法在 vb.net 中做到这一点?

谢谢!

【问题讨论】:

    标签: asp.net vb.net


    【解决方案1】:

    我认为你需要使用类似的东西

    ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType(), New Guid().ToString(), "$('#mainGameBattle').load('http://example.com/spaceArena.aspx?battleID=" & thisBattle.ID & "');")
    

    我可能使用了不正确的参数!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-18
      • 1970-01-01
      • 2016-02-04
      • 2012-01-04
      • 1970-01-01
      • 1970-01-01
      • 2012-02-16
      • 2017-03-29
      相关资源
      最近更新 更多