Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing Action (VS.net 2002/VB and ASP)

    If this should be posted elsewhere please move it. I am listing it here because I think the problem lies in the .net code.

    I have an html text box and submit button in an .aspx file. The form action is to go to a second .aspx form but when the code is process the action changes to the name of the original page. The following html code is part of Field.aspx.

    <pre>
    <form name="form1" method="post" runat="server" action="FORSview.aspx">
    <input type='text' name='txtZip' size='10'>

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Action (VS.net 2002/VB and ASP)

    Hi Loren Ann,

    Working with ASP.NET is quite different from working with classic ASP. I built ASP apps for almost 2 years before starting with ASP.NET and it took WEEKS to sink in!

    Here's the concept: ASP.NET pages post back to themselves (by default) rather than to another page for processing. This totally changes the way you must approach your application design. After doing it this way for some time, I will assure you that it works MUCH better than classic ASP. It's faster, more reliable, event-driven, and takes MUCH less code!

    The "nonsense" you're seeing in the hidden input field is called Viewstate. This is ASP.NET's built-in way of preserving the values of controls (text boxes, labels, datagrids, etc.) between posts (to the same page, that is). This prevents the need to write code to re-display the value entered in the textbox before the submit button was clicked.

    From your code, I see that you're mixing client-side and server-side controls. You've set your Form to run at the server, but your other controls are standard HTML input controls. To make this work, you'll want to approach it one of two ways:
    1) Remove the runat=server attribute of your form tag and everything should work the way you expect it (a la Classic ASP)
    2) Change the textbox to an asp textbox (<asp:textbox id="txtZIP" runat="server" columns="10" />) and the Submit button to an asp button (<asp:button id="btnSubmit" runat="server" text="Go" />), finally move the processing code from your target page (FORSview.aspx) to the On_Click() event of the Submit button (btnSubmit_On_Click()). You can do this using a Code Behind page or inline using the <script runat="server"></script> tags. If you're working with MS Visual Studio.NET, I would recommend using Code Behind, otherwise use inline server-script tags.

    Please post back if you're still having trouble. In the meantime, you might consider reading up a bit on ASP.NET from one of my favorite websites: http://www.4guysfromrolla.com. They have great explanations of almost every ASP.NET concept.

    I hope this helps! Good luck!

  3. #3
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Action (VS.net 2002/VB and ASP)

    Mark, you

  4. #4
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    vancouver, BC, Br. Columbia
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Action (VS.net 2002/VB and ASP)

    Thanks Mark for your reply to Loren Ann which I read with interest -- the whole idea of how ASP.NET posts back to itself and how this influences application design fascinates me. I'll check out http://www.4guysfromrolla.com. too.

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Action (VS.net 2002/VB and ASP)

    You're quite welcome!

    ASP.NET is a great rapid development platform. I found the learning curve a bit steep at first. But after getting the hang of it I could never go back to Classic ASP.

    I did not do much Visual Basic or other Windows-based development before learning ASP.NET, but it seems that people familiar with Windows programming environments will have a bit easier time transitioning to ASP.NET than those of us who came from classic ASP. The entire concept is event-driven: When the user clicks a button on the webpage, it fires the Button_OnClick() event in the code. This is very similar to Visual Basic.

    Another part of the .NET platform that I'm quite attached to is the use of middle-tier business logic components. With this architecture, you can build powerful, reusable components (compiled as DLL files) that can be used in conjunction with ANY interface environment (Web, Windows, Smart Phone, etc.). This can save a lot of development time (and therefore money) in a very short timespan.

    As I may have mentioned before, I do mostly ASP.NET develompent for my company (a fashion-clothing company), but we're starting to look at expanding to more Windows development. Also, I have only used VB as my .NET language of choice so far, but I'm planning to learn some C# in the near future. (This will help some as I start to use Macromedia's Flash as a front-end tool as well...)

    Sorry for being long-winded. The bottom line is that I'm very excited about the .NET platform and I look forward to answering any questions I can in order to help share that excitement with others! <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

  6. #6
    Lounger
    Join Date
    May 2002
    Location
    Fort Worth, Texas, USA
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Changing Action (VS.net 2002/VB and ASP)

    I am the opposite in that I have a VB/VBA background with some HTML. I found myself jumping right into the code behind the HTML. I have practically no experience with classic ASP and have been assigned to make an update to an ASP page.

    I am NOT looking forward to going back. <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •