[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

650 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