Using Redirect with Hidden Fields

Last post 08-17-2009 6:06 AM by shahed.kazi. 3 replies.

Sort Posts:

  • Using Redirect with Hidden Fields

    08-12-2009, 10:50 AM
    • Participant
      999 point Participant
    • Armysniper
    • Member since 06-21-2003, 10:37 AM
    • Boston, MA
    • Posts 283

    I am trying to create a control to allow users to add themselves to our Constant Contact newsletter. I got code from them that contains a <form> so I decided to creaet a control to avoid that. Problem is that I am using SiteFinity...they do not support using PostBackUrl on a button in their content editors. Their response to fix the bug in their system, was to use Response.Redirect. Problem is that there are hidden fields in the control (shown below). I really dont want to have to dig into their API as this should work. How can I get it so that the control will submit to Constant Contact's site without using PostBackUrl on the button?? Here is what I have:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="NewsletterSignup.ascx.cs"
        Inherits="NewsletterSignup" %>
    <h2>
        Subscribe to Leadership Matters
    </h2>
    <p>
        Submit your email to receive our monthly newsletter dedicated to career and recruiting
        related topics.
    </p>
    <div style="text-align: left;">
        <div style="width: 226px; height: 70px;">
            <span style="background-color: #006699; margin-top: 2px; float: left; margin-left: 2px;
                margin-right: 2px;">
                <img alt="" style="border-bottom: 0px solid; border-left: 0px solid; border-top: 0px solid;
                    border-right: 0px solid;" src="http://img.constantcontact.com/ui/images1/visitor/email1_trans.gif" />
            </span>
            <input style="border-bottom: #999999 1px solid; border-left: #999999 1px solid; font-family: verdana,geneva,arial,helvetica,sans-serif;
                border-top: #999999 1px solid; border-right: #999999 1px solid;" type="text"
                name="ea" />
            <asp:Button ID="Submit" runat="server" Style="font-family: verdana,arial,helvetica,sans-serif;
                font-size: 10px;" Text="GO" OnClick="Submit_Click"></asp:Button><br />
            <input value="1100358239499" type="hidden" name="m" />
            <input value="oi" type="hidden" name="p" />
        </div>
    </div>
    Here is the code behind...simple:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class NewsletterSignup : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        protected void Submit_Click(object sender, EventArgs e)
        {
            Server.Transfer("http://visitor.constantcontact.com/d.jsp", true);
        }
    }
    


     

  • Re: Using Redirect with Hidden Fields

    08-12-2009, 11:07 AM
    Answer
    • Participant
      1,470 point Participant
    • Heloril
    • Member since 10-30-2007, 1:38 PM
    • Belgium
    • Posts 255

     Hi,

     

    You can use their code with <form>, if you put a runat="server" in the <form> tag like this:

    <form runat="Server" id="formNewsletter">

    Their code goes here.

    </form>

     

    Regards,
    Helori.

    Mark as Answer if this reply helps you

    My blog: http://www.notesfor.net/
  • Re: Using Redirect with Hidden Fields

    08-17-2009, 5:38 AM
    Answer

    Hi Armysniper,

    You can use javascript to change form action property and submit it to different webpage.

              document.form1.action=".../b.html";  
              document.form1.target="_self";  
              document.form1.submit();  
       
              document.form1.action=".../c.html";  
              document.form1.target="_self";  
              document.form1.submit();

    Sincerely,
    Hua Jun Li
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Using Redirect with Hidden Fields

    08-17-2009, 6:06 AM
    • Star
      11,839 point Star
    • shahed.kazi
    • Member since 07-09-2008, 2:15 AM
    • Sydney, Australia
    • Posts 2,328

    Can you explain what is required. This is a user control - why can't you post back the data to this particular page. If you are trying to submit the form to the jsp page, then you best bet is to use query strings.

Page 1 of 1 (4 items)