Hi - I have jQuery loading content from an aspx page - however, once this is loaded, jQuery doesn't appear to "see" the content. For example, in the code below, I am retrieving a table, with the class "stripeme" from the aspx page - I then try to add the mouseover/alternate row scripts, but my table does not change.
My main page is:
-
(page head info removed for length)
- <script type="text/javascript">
- function showDetails() {
- var div = $("#divResult");
- div.slideUp(function () {
- div.load("getContent.aspx",
- { action: $("#TextBox1").val(),action2: $("#TextBox2").val() },
- function () {
- $(this).slideDown();
- });
- });
- } $(document).ready(function () {
- $(".stripeme tr").mouseover(function () {
- $(this).addClass("over");
- });
- $(".stripeme tr:even").addClass("alt");
- });
- </script>
- <link href="Styles/Site.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <form id="form1" runat="server">
- <div class="page">
- Enter ID to get Details:
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
- <input type="button" id="btnGetDetail" value="Click me"
- Onclick="showDetails();" /><br />
- <asp:Image ID="imgLoading" ImageUrl="~/images/loading.gif" style="display:none" runat="server" />
- <div id="divResult" style="width:420px">
- </div>
- </div>
- </form>
- </body>
- </html>
The getContent.aspx code is: <%
@ Page Language="VB" AutoEventWireup="false" CodeFile="getContent.aspx.vb" Inherits="getContent" %> <!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <
html xmlns="http://www.w3.org/1999/xhtml"> <
head runat="server"> <title></title>
</head><body><form id="form1" runat="server">
<div id="myContent">
<asp:PlaceHolder ID="ph1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div></form></body>
</html>
...and the aspx.vb code is:
-
Partial
Class getContent -
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim symbol As String = If(Request.Params("action"), "")
Label1.Text = Request.Params("action")
-
Dim da As New dsTableAdapters.agentinfoTableAdapter
-
Dim dt As ds.agentinfoDataTable
-
dt = da.GetDataByName(symbol)
-
Dim sb As New StringBuilder
-
'build table with class "stripeme"
-
sb.Append("<table class=""stripeme"">")
-
sb.Append("<th><td>Name</td><td>BU</td><td>Desk</td></tr>")
-
For Each agent As ds.agentinfoRow In dt.Rows
-
sb.Append(String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>", agent.agentName, agent.BU, agent.ClientDesk))
-
Next
-
sb.Append("</table>")
-
'add table to the page
-
ph1.Controls.Add(New LiteralControl(sb.ToString))
-
End Sub
-
End Class
Should I add dynamic content, that I then want to manipulate using jQuery, in some other way?
Thank you very much for any assistance with this,
Mark