Solved

c#/textarea - - issue with return from server//roundtrip

Posted on 2013-12-08
3
451 Views
Last Modified: 2013-12-10
the user enters a value and it makes it to the server and returns back to the client side....an alert box



everything works until it makes it back to the client from the server...an alert box is brought up showing that the values have attached to the textareas from the server...I clcik okay and the page returns and now the textareas are empty...what???



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="this_is_fine_no_worries.aspx.cs" Inherits="" %>

<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
    <script src="http://code.jquery.com/jquery-1.5.min.js" language="javascript" type="text/javascript"></script> 
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

    <script language="javascript" type="text/javascript">

        var touched = false;
        var timer = null;
        var timeout = 4000; // 4 seconds

        var timer;
        var page_answer_ready;

        function after_answer() {

            if (page_answer_ready == true) {
                $("#TextArea2").text(answer);

            }


        }



   
        $(document).ready(function () {
            // Handler for .ready() called.

            if (page_answer_ready == true) {
                $("#TextArea2").text(answer);

            }

        });


    

        function startSearchTime(e) {
            window.clearTimeout(timer);
            var unicode = e.keyCode ? e.keyCode : e.charCode

            var timeToWait = 2000; // time in milliseconds;
            timer = window.setTimeout("doSearch()", timeToWait);
        }

        function doSearch() {
            window.clearTimeout(timer);
            // document.getElementById("Button1").click();
            CallSum()
        }


        var get_text;
        function CallSum() {
            alert("Hi there!");
            //////var txt1 = $get("</%= hotarea.ClientID %>");
            var txtresult = $get("txtSum");
            //var txtresult = "no value";
            get_text = $("#TextArea1").val();
            //PageMethods.Sum(txt1.value, OnCallSumComplete, OnCallSumError,txtresult);
            //PageMethods.Sum(txt1.value, OnCallSumComplete, OnCallSumError);
            PageMethods.Sum(get_text, OnCallSumComplete, OnCallSumError, txtresult);
        }

        var answer;
        var change_message;
        //function OnCallSumComplete(result, txtresult,methodName) {
        function OnCallSumComplete(result) {
            page_answer_ready = true;
            //Show the result in txtresult
            answer = result;
            //txtresult.value = result;
            alert(result);
            change_message = answer + "this message";
          $("#TextArea2").text(change_message);
         // document.getElementById('#TextArea2').value = result;
          
            $("label_answer").text(answer);
            alert(result);
        }

        function OnCallSumError(error, userContext, methodName) {
            // if (error !== null) {
            alert(error.get_message());
            // }
        }

        function $get(id) {
            return document.getElementById(id);
        }

// -->
</script>
    <style type="text/css">
        #TextArea1
        {
            width: 425px;
            height: 234px;
        }
        
         #TextArea2
        {
            width: 425px;
            height: 234px;
        }
        
        
           #hotarea
        {
            height: 192px;
            width: 424px;
        }
        
        #hotarea
        {
            height: 192px;
            width: 424px;
        }
    </style>
</head>
<body onload="after_answer()">
    <form id="form1" runat="server">
    <div>
    
        </div>
    <p>
        txtsum (Get a value to send to server)</p>
    <textarea id="TextArea1" run="server" cols="20" rows="2"></textarea>
    
    <p>
        &nbsp;</p>

        <br />
        <div id="Button_Click" onclick="CallSum()">
            <input type="submit" id="input_submit" value="Submit" />       
        </div>



    <p>
        hotarea (user input sent to server and now back)</p>
    
    <div id="div_TA2">
   
        <textarea id="TextArea2" cols="20" rows="2"></textarea>
        <input type="text" id="text_answer" />
        <label id="label_answer"></label>
    </div>
    
    <p>
        &nbsp;</p>
    <p>
        &nbsp;</p>
        <asp:scriptmanager ID="Scriptmanager1" runat="server" EnablePageMethods="true"></asp:scriptmanager>
    </form>
</body>
</html>

//===============
//===========
//===========
// code behind




using System.Data.SqlClient;
using System.IO;
//using System.Data.SqlClient.SqlDataAdapter;
//using System.Data.SqlClient.SqlConnection;
//using System.String;
//using System.StringComparison;
//using System.Text.StringBuilder;
//using System.Web.UI;
//using System.Web.UI.Page;
//using System.Web.UI.WebControls.TextBox;
//using System.Web.UI.WebControls;
//using System.Web.UI.ExtenderControl;
//using System.Random;
//using System.DateTime;
using System.Data.OleDb;
using System.Text;
using System.Data.Odbc;
using System.Data;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
//using System.Web.SessionState.HttpSessionState;

public partial class my_page : System.Web.UI.Page
{
    


    
    [System.Web.Services.WebMethod()]
     public static string Sum(String arg1)
    {
        // ' http://www.experts-exchange.com/Programming/Languages/.NET/Q_26878831.html
        // stackoverflow.com/questions/16775117/asp-net-scriptmanager-pagemethods-is-undefined


        arg1 = " made it to the server";

        return arg1;

    }


}

Open in new window

0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Author Comment

by:GlobaLevel
ID: 39705248
anyone??
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 39705410
Use ASP.Net TextBox control and set its TextMode to Multiline.

<asp:TextBox TextMode="Multiline" id="TextAread" />

Open in new window

0
 
LVL 10

Author Closing Comment

by:GlobaLevel
ID: 39710532
good
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question