Forms in webpages

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
User avatar
crockettdunn
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 105
Joined: Sun Oct 26, 2008 6:32 pm
Contact:

Re: Forms in webpages

Post by crockettdunn » Mon Oct 27, 2008 3:47 pm

I've been dealing with the same issue for a few years when my CMS vendor updated from ASP 3.0 VB Script to ASP .Net C#

Nested forms aren't allowed, so, I use what I call my sledgehammer approach: onfocus() or onClick events for each input element, causing "this.form.action='somethingnew'" and "this.form.method='something new'".

So wherever a user tabs or clicks, the SINGLE form target and method are changed as is appropriate.

I think there is an example on the home page @ http://www.clinixusa.com/. something like this:

Code: Select all

<p><input onfocus="this.form.action='http://www.google.com/search';this.form.method='GET';" maxlength="255" size="25" name="q"> <input onclick="this.form.action='http://www.google.com/search';this.form.method='GET';" name="btnG" value="SEARCH" type="submit"> <font size="-1"><input name="domains" value="http://www.clinixusa.com" type="hidden"> </font><font size="-1"><br><input name="sitesearch" value="on" type="radio">www <input checked="checked" name="sitesearch" value="http://www.clinixusa.com" type="radio"> CLINIX</font></p>
My next trick to solve is to have the onBlur() event set the form attributes back to their previous values.

hope this helps somebody.

Cheers
Crockett Dunn
Owner, CDLLC
866.888.7134
http://www.crockettdunn.com
Last edited by crockettdunn on Tue Nov 18, 2008 7:15 pm, edited 1 time in total.

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forms in webpages

Post by Brewhaus » Wed Oct 29, 2008 6:47 pm

Is there a way to give the customer the ability to attach a file to the form so that we receive the attachment when the form is received?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forms in webpages

Post by mazhar » Thu Oct 30, 2008 7:56 am

Is there a way to give the customer the ability to attach a file to the form so that we receive the attachment when the form is received?
Yes you can use the ASP.NET FileUpload control for this purpose. A good example is the
Admin/Products/Assets/UploadAdditionalImages.aspx page.

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forms in webpages

Post by Brewhaus » Mon Nov 03, 2008 8:58 pm

Can this be set up to attach the file to the e-mail that the form sends?
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forms in webpages

Post by mazhar » Tue Nov 04, 2008 6:15 am

Can this be set up to attach the file to the e-mail that the form sends?
Yes this is possible. I just updated the ContactUs control available in the following post to incorporate the attachment functionality. Please check the following post
viewtopic.php?f=47&t=7954&p=37807#p37807

Brewhaus
Vice Admiral (VADM)
Vice Admiral (VADM)
Posts: 878
Joined: Sat Jan 19, 2008 4:30 pm

Re: Forms in webpages

Post by Brewhaus » Tue Nov 04, 2008 10:22 pm

That works great. I had used a previous version that was all incorporated in a single .ascx file, so I had to make some adjustments to add my fields, but all seems to be working. :D
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot

Ron
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Nov 13, 2008 8:38 am

Re: Forms in webpages

Post by Ron » Mon Nov 17, 2008 10:50 am

Continuing this discussion on handling nested forms, I am certainly new to .Net and am helping someone migrate their site app from .ASP to the Able platform. One of the things I've been asked to do and struggling with is embedding the Google Mapping API into the site to allow generating directions to the store. The API uses Javascript functions to format and pass parameters for the From and To locations. I have those functions in the header of the page and have the form set with a defaulted 'To' location.
I need a little help understanding how I might direct the this.form.action to pass the form fields to the pages header script and execute the script rather than being treated as an external page link.
The Google supplied form onsubmit executes the setdirection function which passes the parameters to the API calls to return the appropriate map and directions. And seeing that onsubmit did not seem to work I looked here in the discussion to see how others got by the form problem and came across the control definition of onclick in the this.form.action which I've applied to the Get Directions button but treates the function call as an external page link.
Anyone tell me where I might look to get a better understanding how to do this?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forms in webpages

Post by mazhar » Mon Nov 17, 2008 10:55 am

Regarding Google Maps have a look at this post
viewtopic.php?f=42&t=8451

Ron
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Nov 13, 2008 8:38 am

Re: Forms in webpages

Post by Ron » Mon Nov 17, 2008 3:09 pm

Mazhar,

Thanks for the post reference. I will look into it in more detail, but first glance indicates the solution is around a fairly static map and placing pins on it rather than a dynamic map with generated driving directions. I'd have to learn more about that solution and the API coding to see if different mapping methods could be delivered using the code.

As I indicated, everything implemented from the example broken up into the header and content sections is working with exception of the Form input. I can get the mapping and driving directions just fine if I specify 'from' and 'to' locations in the SetDirections call in the Initialize function. I can't seem to get the process to work from the Form submit side and I'm not sure where it fails that would prevent it from getting values to supply to the Google API's. When the form "Get Directions!" button is pushed, basically the page comes back with the initial result - like the OnLoad initialize function has fired, overriding the submitted values, or the values are not getting picked up from the form, or the button is not actually invoking the SetDirections function as a result of the form being nested in the application.

I am thinking there is something not working with the submit form process than the API functionality.

ron

User avatar
Jaz
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Nov 05, 2008 4:04 am
Location: Torrance, CA
Contact:

Re: Forms in webpages

Post by Jaz » Wed Nov 19, 2008 4:31 am

I’m still having some trouble posting my signup box for my email list. I tried to use mazhar's method, but think my programming is a little rusty. Here is the HTML code I am currently using on my old site:

Code: Select all

<form action="http://ui.constantcontact.com/d.jsp" method="post" name="ccoptin" target="_blank" id="ccoptin" style="margin-bottom:2;">
     <input type="hidden" name="m" value="1101475813245" />
     <input type="hidden" name="p" value="oi" />
     <font style="font-weight: normal; font-family:'Arial Narrow','Arial MT Condensed Light',sans-serif; font-size:13px; color:#FFFFFF;">Add your email to join our mailing list:</font>
     <input type="text" name="ea" size="20" value="" style="font-size:10pt; border:1px solid #999999;" />
     <input type="submit" name="go" value="Go" class="submit" style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif; font-size:10pt;" />
   </form>
If someone wants to tackle this, feel free to send me a quote for the work.
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forms in webpages

Post by mazhar » Wed Nov 19, 2008 5:22 am

Create a new file FormTest.ascx in the ConLib folder, put the following code in it and then use that control on your store pages

Code: Select all

<%@ Control Language="C#" ClassName="FormTest" %>
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Form.Name = "ccoptin";
        Page.Form.Target = "_blank";
    }
</script>
<input type="hidden" name="m" value="1101475813245" />
<input type="hidden" name="p" value="oi" />
<font style="font-weight: normal; font-family:'Arial Narrow','Arial MT Condensed Light',sans-serif; font-size:13px; color:#FFFFFF;">Add your email to join our mailing list:</font>
<input type="text" name="ea" size="20" value="" style="font-size:10pt; border:1px solid #999999;" />
<asp:Button ID="SubmitButton" runat="server" Text="Button" PostBackUrl="http://ui.constantcontact.com/d.jsp" />

User avatar
Jaz
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Nov 05, 2008 4:04 am
Location: Torrance, CA
Contact:

Re: Forms in webpages

Post by Jaz » Wed Nov 19, 2008 6:01 am

Perfect!!!!
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --

Ron
Ensign (ENS)
Ensign (ENS)
Posts: 13
Joined: Thu Nov 13, 2008 8:38 am

Re: Forms in webpages

Post by Ron » Wed Nov 19, 2008 1:18 pm

For those that might be interested in embedding Google directions mapping API's into their Able site, I have finally worked thru the issues I had and have the Google directions-advanced.html example code working.

And not knowing .Net or Javascript it took a bit longer for me than probably for any of you to get thru the frustration of nested forms in .Net

The code was taken from the Google site page source view when looking at the example (http://code.google.com/apis/maps/docume ... anced.html). From the simple page source they provided, I separated the code, from the <script> statement down through the </head> <body onload="initialize()" ununload="GUnload()"> statements and pasted them into the header section of a new scriplet created. In that code, I signed up for and included the API key given from Google and I also modified the default 'from' and 'to' locations provided in the example setDirections call in the initialize() function to both be set to the destination address for the initial page load map drawing. Pretty straightforward.

The main changes come in migrating the Form portion of the page into the Content section in the Able scriplet maintenance. The easiest solution for forms in ASP.net appears to be to remove the <form> and </form> tags since every .Net page is already in a form and you can't nest forms, .Net or otherwise. Then change the onsubmit form function with an onclick event and you are about done which for me, looked like this:
<input name="submit" type="submit" value="Get Directions!" onclick="setDirections(from.value, to.value, locale.value); return false" />

Not knowing Javascript, I struggled in the parameters to be passed to the function, but once I started debugging the javascript side, I was able to figure it out.

I hope I am not preaching to the choir here on how this was done, and what I think might be an easy solution to incorporating forms-like capabilities into your .Net app particularly if you are looking at migrating HTML forms or ASP content into your .Net app. But after a frustrating few days, I got past my problem with what turns out to be a fairly simple solution.

User avatar
Jaz
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Nov 05, 2008 4:04 am
Location: Torrance, CA
Contact:

Re: Forms in webpages

Post by Jaz » Tue Feb 24, 2009 4:02 am

I have been using mazhar's method for my sign up box for my email list and it has worked great until now. Now when a customer adds their email and clicks "submit" the get the following error:

Request-URI Too Large

The requested URL's length exceeds the capacity limit for this server.
IBM_HTTP_Server Server at p2-ws570 Port 80

Any guess on how to deal with this?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Forms in webpages

Post by mazhar » Tue Feb 24, 2009 7:22 am

Well my knowledge about this issue is dependent on Google. It seems that this is due to a long query string which in fact exceeds the maximum length of URL. Have a look at following thread
http://www.facileforms.biz/forum/index. ... 7.msg20861

User avatar
Jaz
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Nov 05, 2008 4:04 am
Location: Torrance, CA
Contact:

Re: Forms in webpages

Post by Jaz » Tue Feb 24, 2009 2:25 pm

Yea - I saw that. I guess they are limited to 255 characters. The weird thing is that I have the same sign up form a PHP page ant it works fine. Is there something about ASP that would make the URL longer?
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --

User avatar
Jaz
Captain (CAPT)
Captain (CAPT)
Posts: 245
Joined: Wed Nov 05, 2008 4:04 am
Location: Torrance, CA
Contact:

Re: Forms in webpages

Post by Jaz » Mon Mar 22, 2010 2:50 am

Just a note for anyone that is trying to use this code. Constant contact has changed their URL from:

http://ui.constantcontact.com/d.jsp

to

http://visitor.constantcontact.com/d.jsp

I had not make the update to get it to work.

Also, make sure you put in your unique identifier, or you will be sending people to my email list.
David Jasiewicz
President
Trick Concepts - Metal Fab. Engineering and Product Design
http://www.trickconcepts.com-- If you are an ASP or PHP programmer or CSS web specialist I will gladly trade for graphic design, mechanical engineering or metal fabrication service! --

Richard47
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Nov 04, 2010 1:15 pm

Re: Forms in webpages

Post by Richard47 » Thu Nov 04, 2010 1:48 pm

Ok I'm going nuts here. we are using campain monitor for our emails and they to use a form for there posting. Need some help getting this to work.

there code...........

<form action="http://yourstore.createsend.com/t/y/s/vtyd/" method="post">
<table cellspacing="0" cellpadding="4" border="0" width="560">
<tr valign="top"><td><br />Are you in <b>The Know?</b> If you're not receiving our monthly emails then you're missing out on exclusive sales, coupons and first dibs on new and retiring products.<br /><br />
So what are you waiting for??? Enter your email address and name below.<br /><br />
<u>Privacy:</u> Something More Store does not send unsolicited email (SPAM) or share your email address with anyone. We respect your privacy. If you no longer wish to receive email from us, simply click the Unsubscribe link at the top of every email. It's that simple.<br /><br />
All of our newsletters require an opt-in confirmation. To start your subscription, enter your First & Last name, and email address then click on Subscribe to submit your request. The confirmation email will be sent to your email address.<br /><br /></td>
</tr>
</table>
<table cellspacing="0" cellpadding="4" border="0" width="560">
<tr>
<td align="right"><label for="name">Name:</label></td>
<td><input type="text" name="cm-name" id="name" size="20" /></td>
</tr>
<tr valign="top">
<td align="right"><label for="vtyd-vtyd">Email address:</label></td>
<td><input type="text" name="cm-vtyd-vtyd" id="vtyd-vtyd" size="20" /></td>
</tr>
<tr valign="top">
<td></td>
<td><input type="submit" value="Subscribe" /></td>
</tr>
</table>
</form>

anyone have some help
TIA

Richard47
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 47
Joined: Thu Nov 04, 2010 1:15 pm

Re: Forms in webpages

Post by Richard47 » Tue Nov 09, 2010 5:07 pm

Richard47 wrote:Ok I'm going nuts here. we are using campain monitor for our emails and they to use a form for there posting. Need some help getting this to work.

there code...........

<form action="http://yourstore.createsend.com/t/y/s/vtyd/" method="post">
<table cellspacing="0" cellpadding="4" border="0" width="560">
<tr valign="top"><td><br />Are you in <b>The Know?</b> If you're not receiving our monthly emails then you're missing out on exclusive sales, coupons and first dibs on new and retiring products.<br /><br />
So what are you waiting for??? Enter your email address and name below.<br /><br />
<u>Privacy:</u> Something More Store does not send unsolicited email (SPAM) or share your email address with anyone. We respect your privacy. If you no longer wish to receive email from us, simply click the Unsubscribe link at the top of every email. It's that simple.<br /><br />
All of our newsletters require an opt-in confirmation. To start your subscription, enter your First & Last name, and email address then click on Subscribe to submit your request. The confirmation email will be sent to your email address.<br /><br /></td>
</tr>
</table>
<table cellspacing="0" cellpadding="4" border="0" width="560">
<tr>
<td align="right"><label for="name">Name:</label></td>
<td><input type="text" name="cm-name" id="name" size="20" /></td>
</tr>
<tr valign="top">
<td align="right"><label for="vtyd-vtyd">Email address:</label></td>
<td><input type="text" name="cm-vtyd-vtyd" id="vtyd-vtyd" size="20" /></td>
</tr>
<tr valign="top">
<td></td>
<td><input type="submit" value="Subscribe" /></td>
</tr>
</table>
</form>

anyone have some help
TIA

Never Mind I figured it out.

Post Reply