MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Jquery (Closed) (Mono Support )

Viewed 18709 time(s), 4 post(s) 8/22/2011 4:39:49 PMby shawndg
shawndg

shawndg

8/22/2011 4:39:49 PM
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..
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

8/22/2011 4:52:55 PM
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?
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

8/22/2011 5:51:26 PM
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>


This content has not been rated yet. 
1871 Reputation 252 Total posts
shawndg

shawndg

8/22/2011 5:58:37 PM
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();
}
This content has not been rated yet. 
1871 Reputation 252 Total posts