Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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
  #1 (permalink)  
Old July 7th, 2006, 06:25 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default Compiler Error Message: BC30456:

I have this small piece of code in my ASP.NEt page, I am attempting to post the information in the textbox to another page. But it doesnt seem to be working? Anyone got any ideas? I have looked it up, but I am not finding much???

Code:
<%@ Page Language="VB" %>
<script runat="server">

    ' Insert page code here
    '

</script>
<html>
<head>
</head>
<body>
    <form name="form" action="postForm2.aspx" method="post" id="postForm" runat="server">
        <asp:Textbox id="theTextbox" runat="server" />
        <asp:Button id="Submit" onClick="document.form.submit();" runat="server" />
    </form>
</body>
</html>
My error:

Compiler Error Message: BC30456: 'document' is not a member of 'ASP.postForm_aspx'.

the line:
<asp:Button id="Submit" onClick="document.form.submit();" runat="server" />

Cheers.

Picco

www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
  #2 (permalink)  
Old July 7th, 2006, 06:31 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Ah, i found something (that i didnt think would work) - but it did
Code:
<%@ Page Language="VB" %>
<script runat="server">

    ' Insert page code here
    '
Sub SubmitForm(o As Object, e As EventArgs)
    Dim webbrowser
    webbrowser.Navigate("javascript:document.form.submit();")
End Sub
</script>
<html>
<head>
</head>
<body>
    <form name="form" action="postForm2.aspx" method="post" id="postForm" runat="server">
        <asp:Textbox id="theTextbox" runat="server" />
        <asp:Button id="Submit" onClick="SubmitForm" runat="server" Text="Submit" />
    </form>
</body>
</html>
thats thw working code, now postForm2.aspx looks like this:
Code:
<%@ Page Language="VB" Debug="True" %>
<script runat="server">

Sub Page_Load
    If Not Page.PreviousPage Is Nothing Then
        Dim SourceTextBox As TextBox
        SourceTextBox = CType(PreviousPage.FindControl("theTextbox"), _
            TextBox)
        If Not SourceTextBox Is Nothing Then
            Label1.Text = SourceTextBox.Text
        End If
    End If
End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">

    </form>
</body>
</html>
Should that not be able to pick up what is in theTextbox form field?

Cheers

www.crmpicco.co.uk
www.ie7.com
  #3 (permalink)  
Old July 8th, 2006, 03:50 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

ASP.NET (1.x and 2) pages by default post back to themselves. If you look at the resulting HTML in the browser, you'll see .NET has changed the form tag for you.

In ASP.NET 2 there is something called "cross page posting" that allows you to post information from one page to another. You seem to be using this, but you need to enable cross page posting on the first page as well by setting the relevant properties on the buttons that cause the submit, and not with tricks that submit the form with a webbrowser or client side script.

Quite often you don't need CPP. You just have to get used to the single page, post back mechanism.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
  #4 (permalink)  
Old November 30th, 2006, 07:40 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

thanks Imar, appreciated help

www.crmpicco.co.uk
www.ie7.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler Error Message: BC30456: 'dgproducts_editc sunitha50 ASP.NET 2.0 Basics 0 February 27th, 2007 12:43 PM
Compiler Error Message: BC30456 yaip All Other Wrox Books 6 October 12th, 2006 02:56 PM
Compiler Error Message: CS1010: Newline in constan @shish Crystal Reports 0 May 10th, 2006 04:39 AM
Compiler Error BC30456 Dwizz ASP.NET 1.0 and 1.1 Basics 3 November 9th, 2005 11:30 AM
Compiler Error Message: CS0246: The type or namesp frmsasp All Other Wrox Books 0 September 17th, 2005 09:13 AM





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