Mono Support Jquery (Closed)

Viewed 19834 time(s), 4 post(s), 8/22/2011 4:39:49 PM - by shawndg
8/22/2011 4:39:49 PM
1871 Reputation 252 Total posts

Hello,

First.. let me apologize if this is not MonoX specific error because I am just starting to learn jquery.

I was going thru a turtorial online on how to use jquery to simulate panel behavior in asp.net by loading pages into <div areas>

This looks like it could solve a lot of my odd issues but my biggest issue with it is that so far I have been unable to get it to work inside Monox..

Its a very simple concept.. and the jquery code appears to fire but the MonoX side.. where I have my code behind.. does not seem to be reading my input.

First I have a simple aspx page in Monox.

<%@ Page Title="" Language="C#" MasterPageFile="/MonoX/MasterPages/MonoX.master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ProjectName.Web.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" runat="server">
 
<script type="text/javascript">
 
    function test() {
 
        $("#divResult").load("testpanels.aspx",
       { testreq: $("#txttest").val() });
 
    }
 
</script>
 
 
<div class="containercontent">
 
    Test Input:
 
    <asp:TextBox runat="server" ID="txttest" Text="testinput.." />      
 
    <input type="button" id="btnSubmit" value="Test"  
 
           onclick="test();" />
 
    <hr />
 
    <div id="divResult"</div>
 
</div>
 
  
</asp:Content>

Then i have a 2nd page..
testpanels.aspx with a very simple markup and some code behind to attempt to read the jquery input.

markup..
<%@ Page Title="" Language="C#" MasterPageFile="/MonoX/MasterPages/MonoX.master" AutoEventWireup="true" CodeBehind="testpanels.aspx.cs" Inherits="ProjectName.Web.TestDisplay" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="cp" runat="server">
 
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
 
</asp:Content>

code behind..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace ProjectName.Web
{
    public partial class TestDisplay : MonoSoftware.MonoX.BasePage
    {
 
        protected void Page_Load(object sender, EventArgs e)
        {
            TestCallBack();
        }
 
 
        protected void TestCallBack()
        {
            string symbol = Request.Params["testreq"] ?? "";
 
            //read all keys..
            foreach (string key in this.Request.QueryString.AllKeys)
            {
                this.Response.Write(String.Format("{0} = {1}<br />", key, Request[key]));
                this.TextBox1.Text = this.TextBox1.Text + key + "-" + Request[key] + "<br>";
                 
            }
 
        }
 
 
    }
 
}

But.. I cant seem to get anything to read the Request.Params["testreq"] ?? in MonoX..

1
8/22/2011 4:52:55 PM
7207 Reputation 956 Total posts

Hi Shawn,
My first suggestion would be to avoid using hash selectors in ASP.NET Web Forms projects ($("#divResult")...), as they are using element's ID, which is in turn manipulated by ASP.NET and changed depending on a control hierarchy on your page. You are referencing both simple HTML elements (like DIVs) and ASP.NET controls (like TextBoxs) via their IDs, which will not work in the latter case. Please add a dummy CSS class to the TextBox (if you don't need a "real" class), and revert to using class selectors ($(".myTxtBoxClass")...)
Does it work after you change that?

2
8/22/2011 5:51:26 PM
1871 Reputation 252 Total posts

thx Denis.. That info was helpful but I am still not getting data on my 2nd page..

the markup for the webform1.aspx page now looks like this..

<%@ Page Title="" Language="C#" MasterPageFile="/MonoX/MasterPages/MonoX.master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ProjectName.Web.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" runat="server">
 
<script type="text/javascript">
 
    function test() {
 
        $(".divResult").load("testpanels.aspx",
       { testreq: $(".dummytxttest").val() });
 
//       alert($(".dummytxttest").val());
 
    }
 
</script>
 
 
<div class="containercontent">
 
    Test Input:
 
    <asp:TextBox runat="server" ID="txttest" Text="testinput.." class="dummytxttest" />      
 
    <input type="button" id="btnSubmit" value="Test"  
 
           onclick="test();" />
 
    <hr />
 
    <div class="divResult"</div>
 
</div>
 
  
</asp:Content>


3
8/22/2011 5:58:37 PM
1871 Reputation 252 Total posts

Thx..

I got it..

i think it may be a combination of things.. with your help and changing the part code below inside my testpanels.aspx
it worked.. thx a ton..

protected void TestCallBack()
{
string symbol = Request.Params["testreq"] ?? "";
this.TextBox1.Text = symbol.ToString();
}

4
This is a demo site for MonoX. Please visit Mono Software for more info.