Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2008, 11:08 AM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default saving data from HTML textarea

I have a HTML textarea that when characters are typed in, client-side javascript determines the word count and displays on the web-page. When I try to write the inputted data from the textarea into my sql database using VB, I'm getting an error "Object not set to an instance of an object". I think this is because my textarea does not contain the runat="server" tag. If I add this, then my client-side word count doesn't work anymore. Is there a way I can pull data from the HTML textarea using vb on page submit and keep the client-side javascript working?

Any help on this would be greatly appreciated.

 
Old May 8th, 2008, 01:24 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You’re going to have to provide more info.
For instance, what is the line of code that raises “Object not set to an instance of an object”?
 
Old May 8th, 2008, 01:39 PM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is the javascript code:

  <script language="javascript">
        var count = "2000";
        function limiter(){
            var tex = document.Form1.comment.value;
            var len = tex.length;
            if(len > count){
                tex = tex.substring(0,count);
                document.Form1.comment.value =tex;
                return false;
            }
            document.Form1.limit.value = count-len;
        }
        </script>

this is the layout of the html code:

<textarea id="taproblem" name="comment" wrap="hard" rows="6" cols="100" onkeyup="limiter()" class="label2"></textarea><br>
<script language="javascript"> document.write("<input type=text name=limit size=4 readonly value="+count+">");
</script>

The VB code is that raises the error happens on the page submit event and is as follows:

  Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
      Dim iCD = taproblem.Value

Do you need more information?

Thank You for your assistance!


 
Old May 8th, 2008, 05:12 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

It is not a good idea to not specify variable types. Your
Code:
    Dim iCD = taproblem.Value
should be something like
Code:
    Dim iCD As String = taproblem.Value
I suspect that the reference taproblem.Value does not refer to what you think it refers to, and needs to have some further resolution, or you need to use the name instead of the ID, or you need to add .ToString(), or something like that.

Incidentally, if you start a listing with "[ c o d e ]" (but without the spaces or quotes), and end it with "[ / c o d e ]" (without the spaces or quotes) the font will be fixed instead of proportional, and what you see is what you will get once you post it (more or less). That's what I did here (additionally adding color...).
 
Old May 9th, 2008, 09:25 AM
Authorized User
 
Join Date: Sep 2007
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are correct...I added the runat="server" tag back into the textarea, used the ID instead of the name and adjusted my javascript accordingly. The client-side script is working fine and I am now able to extract the data within the textarea for data storage.

Thank you very much.






Similar Threads
Thread Thread Starter Forum Replies Last Post
saving html content as xml data using javascript ravillasubhash Javascript How-To 0 May 23rd, 2007 08:11 AM
saving text from ASP textarea to Access arabuafef Access ASP 3 December 26th, 2006 04:09 AM
TEXTAREA tag in html sapphire87 PHP How-To 0 July 26th, 2006 02:25 PM
html textarea to DB ginoitalo Beginning PHP 1 May 30th, 2005 01:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.