?
Solved

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

Posted on 2013-12-08
3
Medium Priority
?
454 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 2000 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 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