views:

492

answers:

6

In ASP.net, I need the code to fill the text area (in the form) when a button is clicked. Can you help me through by showing a simple .aspx code containing the script tag?

In trying to solve this, I get the following error:

This .aspx document does not contain the definition of addText() function

My .ASPX code is below.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="textarea.aspx.cs" Inherits="textarea" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <textarea id="TextArea1" style="z-index: 100; left: 197px; width: 225px; position: absolute;
            top: 125px; height: 117px" ></textarea>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 101;
            left: 299px; position: absolute; top: 323px" Text="Button" />
    </div>  
    </form>
</body>
</html>
A: 

Doesn't sound like it's specific to asp.net or .aspx code as much as Javascript, right?

<input type='text' id='text_field' name='text_field'>
<input type='button' onClick="document.getElementById('textfield').value = '';">
jerebear
A: 

hi,

      i want to use a function (say addtext() ) where i need to populate the TextArea.. how to use javascript for that..?

(thats y i was asking the entire .aspx code :-) ) and moreover in ur code i'm not sure of the (" ") used as not a matching number of double quotes.

Can u plz give me a full .aspx code containing a function (say addtext() ) ???

stack_pointer is EXTINCT
Read the FAQ's and learn: a) Posting etiquette. b) Formatting guidelines. c) Addressing a technical community in TxtSpk/SMS Lingo makes you seem illiterate and lazy by comparison.
Cerebrus
+1  A: 
<script language='javascript'>
function AddText()
{
    var txtArea = document.getElementByID ( "txtContent" );
    if ( txtArea )
    {
      txtArea.value = "your value";
    } 
}
</script>



<textarea id="txtContent" />
<input type='button' onclick='javascript:AddText();' />
rahul
A: 

so how shall i invoke the function??

this is my .aspx code(BELOW)... I dont know where to place ur Code(function definition) and where to make a call for it ???? Can u help me ?

*<%@ Page Language="C#" AutoEventWireup="true" CodeFile="textarea.aspx.cs" Inherits="textarea" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <textarea id="TextArea1" style="z-index: 100; left: 197px; width: 225px; position: absolute;
            top: 125px; height: 117px" ></textarea>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 101;
            left: 299px; position: absolute; top: 323px" Text="Button" />

    </div>  
    </form>

</body>
</html>*
stack_pointer is EXTINCT
*cringe*. Don't respond to your own question with something which isn't an answer.
Kezzer
A: 

I'm getting an Error ==>

"This .aspx document does not contain the definition of addText() function"

:( so Can u pls paste a full .aspx sample code so that i may know where to have the function definition and where to place a call for it ??

stack_pointer is EXTINCT
A: 

Hi,

      **Can any1 tell how to post the .aspx code**???

When i post my code (as answer) full code doesnot appear as the answer in preview.... some contents in the tag disappear...

I want to post my code bcoz i'm getting frequent errors for my code .

and i need you guys to verify my code for debugging and clear out my errors....

stack_pointer is EXTINCT
Can any1 help??? URGENT
stack_pointer is EXTINCT
You've been given a number of answers above. Try and use those. We aren't here to write your code for you in it's entirety, but we are here to help give snippets of code to help you resolve your errors. You need to try things and learn on your own with what has been given.
SnapJag