Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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 September 18th, 2003, 03:41 PM
Authorized User
 
Join Date: Jul 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newsletter Form UserControl?

Question for you;
The Newsletter form wizard creates an email submit <form> for the newsletter subscription. However I would like to use the email submit in an .aspx page/ or user control. Since you can't have two <form> tags on one .aspx page. How would you change the following form wizard html/code to work in a .aspx page. Heres the code that is created.

<form name="newsletter" action="http://localhost/thephile/modules/lists/subscribe.aspx" method="get">
<input type="hidden" name="ListID" value="14">
<div align="center">
<table>
  <tr><td>Email Address:</td></tr>
  <tr>
    <td><input type="text" name="Email" size="20"></td>
    <td><input type="submit" value="Submit"></td>
  </tr>
  <tr>
    <td colspan="2">
      <input type="radio" name="Action" value="Subscribe" checked>Subscribe
      <input type="radio" name="Action" value="Unsubscribe">Unsubscribe

    </td>
  </tr>
</table>
</div>
</form>


any idea, to change this for aspx
thanks,
d.


 
Old September 26th, 2003, 07:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sup De,

I created an email generic subscription user control that I wanted to add to my website. Creating this user control would allow me to use it anywhere on my site. I was concerned about the Form Tags that already existed on the Mother Page (Default.aspx).

Note: You can't have 2 server form tags on one page anyway.

Here is my old html form. I stripped all the other tags for clarity.

<form name="newsletter" action="http://localhost/Funkysite/webmodules/MailingLists/Subscribe.aspx" method="get" ID="Form1">

<input type="hidden" name="ListId" value="14" ID="Hidden1">


<table ID="Table1">

<tr>

    <td colspan="2">

     First Name:

    </td>

</tr>

<tr>

    <td colspan="2">

     <input type="text" name="FirstName" size="30" ID="Text1">

    </td>

</tr>

<tr>

    <td colspan="2">

     Last Name:

    </td>

</tr>

<tr>

    <td colspan="2">

     <input type="text" name="LastName" size="30" ID="Text2">

    </td>

</tr>

<tr><td>Email Address:</td></tr>

<tr>

    <td><input type="text" name="Email" size="20" ID="Text3"></td>

    <td><input type="submit" value="Submit" ID="Submit1" NAME="Submit1"></td>

</tr>

<tr>

    <td colspan="2">

     <input type="radio" name="Action" value="Subscribe" checked ID="Radio1">Subscribe

     <input type="radio" name="Action" value="Unsubscribe" ID="Radio2">Unsubscribe


    </td>

</tr>

</table>



</form


Here's the new code as a User Control.
I replaced all the html controls with server controls. Note the runat="server" for each control.


    <table height="*" cellSpacing="0" cellPadding="0" width="100" border="0">

        <tr>

            <td class="subscribe">First Name:

            </td>

        </tr>

        <tr>

            <td><asp:textbox id="FirstName" Runat="server"></asp:textbox></td>

        </tr>

        <tr>

            <td class="subscribe">Last Name:

            </td>

        </tr>

        <tr>

            <td><asp:textbox id="LastName" Runat="server"></asp:textbox></td>

        </tr>

        <tr>

            <td class="subscribe">Email Address:

            </td>

        </tr>

        <tr>

            <td><asp:textbox id="Email" Runat="server"></asp:textbox></td>

        </tr>

        <tr>

            <td class="subscribe">

            <asp:radiobutton id="subscribe" runat="server" Text="Subscribe"

            GroupName="Action" Checked="True"></asp:radiobutton><BR>

                <asp:radiobutton id="unsubscribe" runat="server"

                Text="Unsubscribe" GroupName="Action"></asp:radiobutton></td>

        </tr>

        <tr>

            <td><br>

                <asp:button id="submit" onclick="onsubmit_click"

                 runat="server" Text="Submit" cssclass="button"></asp:button></td>

        </tr>

    </table>



<b>Here is the VB. Code behind that took the place of the GET METHOD AND ACTION of the old html form: <b>





         Sub onSubmit_click( _

         ByVal sender As Object, _

         ByVal e As EventArgs) Handles submit.Click



        Dim Fname As String

        Fname = FirstName.Text



        Dim Lname As String

        Lname = LastName.Text



        Dim Mail As String

        Mail = Email.Text

        Dim Subchoice As String

        If subscribe.Checked Then

            Subchoice = "Subcribe"

        Else : Subchoice = "Unsubscribe"

        End If

                Response.Redirect(("~/webmodules/Mailinglists/Subscribe.aspx?ListId=17&FirstName=" & Fname & "&LastName=" & Lname & "&Email=" & Mail & "&Action=" & Subchoice))



    End Sub

The tricky part is the response.redirect string.

Disclaimer: I forgot to spell check. he he

I also hard coded the ListID in the redirect string. If the ListID is not a security issue, you can store it in a hidden server control for easy access. I just choose not to use a hidden control per my requirements.

De, don't forget the books that I suggested on my other post.
 
Old September 29th, 2003, 05:06 PM
Authorized User
 
Join Date: Jul 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again drfunkie for your post,
I actually did just about the same thing you did, before seeing your post using C#. I hard coded the ListID in the code behind too.
;)
_____
d.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Newsletter Mechanism vivek_inos ASP.NET 1.0 and 1.1 Professional 1 September 22nd, 2007 07:38 AM
Where is the newsletter option luisjeronimo BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 July 20th, 2007 03:16 PM
newsletter vantoko BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 28th, 2007 03:28 AM
Newsletter sydneyausguy BOOK: Professional DotNetNuke ASP.NET Portals ISBN: 0-7645-9563-6 1 August 19th, 2005 05:23 PM
help with newsletter question AStuntz Beginning PHP 1 May 13th, 2004 06:54 PM





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