<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adammer - Blog &#187; ASP.NET</title>
	<atom:link href="http://www.adammer.com/blog/tag/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adammer.com/blog</link>
	<description>Official Adammer Blog</description>
	<lastBuildDate>Mon, 10 May 2010 00:09:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Adding HTML Form Submission to the Text/HTML module in DNN</title>
		<link>http://www.adammer.com/blog/2009/06/adding-html-form-submission-to-the-texthtml-module-in-dnn/</link>
		<comments>http://www.adammer.com/blog/2009/06/adding-html-form-submission-to-the-texthtml-module-in-dnn/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 16:10:41 +0000</pubDate>
		<dc:creator>Adammer</dc:creator>
				<category><![CDATA[DotNetNuke]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[DNN Tips]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.adammer.com/blog/?p=38</guid>
		<description><![CDATA[Question: How can I add an HTML &#60;form&#62; element to the Text/HTML module in DNN? Problem: When editors add a &#60;form&#62;&#60;/form&#62; tag to the Source of the Text/HTML module, the &#60;form&#62; tags are removed after they click the Update link on the &#8220;Edit Text/HTML&#8221; form. Cause: ASP.NET only allows one form per page and by [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Question:</strong> How can I add an HTML <code>&lt;form&gt;</code> element to the Text/HTML module in DNN?</p>
<p><strong>Problem:</strong> When editors add a <code>&lt;form&gt;&lt;/form&gt;</code> tag to the Source of the Text/HTML module, the <code>&lt;form&gt;</code> tags are removed after they click the Update link on the &#8220;Edit Text/HTML&#8221; form.</p>
<p><strong>Cause:</strong> ASP.NET only allows one form per page and by default creates its own form just inside the  <code>&lt;body&gt;&lt;/body&gt;</code> tags.</p>
<p><strong>Solution:</strong> Here&#8217;s an example form we will add to our Text/HTML module.</p>
<p><span id="more-38"></span></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://someURL.com&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstName&quot;</span>&gt;</span>Your First Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstName&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your First Name&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your First Name&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lasttName&quot;</span>&gt;</span>Your Last Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lasttName&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your Last Name&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your Last Name&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit Form&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit Form&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span></pre></div></div>

<p>Take note of the Form <code>method</code> and <code>action</code> values.</p>
<p>Locate your submit button input. In our example it is</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit Form&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Submit Form&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>Add the <code>onclick</code> method using the method and action values like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Send Form&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.form.method='post'; this.form.action='http://SomeURL.com/';this.form.submit(); /&gt;</span></span></pre></div></div>

<p>Next we remove the opening and closing <code>&lt;form&gt;&lt;/form&gt;</code>tags so we are left with the following code:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstName&quot;</span>&gt;</span>Your First Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;firstName&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your First Name&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your First Name&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lasttName&quot;</span>&gt;</span>Your Last Name<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lasttName&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your Last Name&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Your Last Name&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Send Form&quot;</span> <span style="color: #000066;">onclick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;this.form.method='post'; this.form.action='http://SomeURL.com/';this.form.submit();&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>We cut and paste this code into the Text/HTML Editor making sure to be in &#8220;Source&#8221; mode. (Make sure the &#8220;Source&#8221; button in the upper left-hand corner of the Editor is highlighted.)</p>
<p>If you need your action to be <code>get</code> not <code>post</code> you can change  <code>this.form.method='get'</code>. This will add the form values as URL parameters.</p>
<p>If you want your form to open a new window on submit you can add <code>this.form.target='blank'</code> as well.</p>
<p>Special thanks to Mitchel Sellers for his <a href="http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/45/allowing-html-form-submissions-from-dnn.aspx">blog about this subject</a>.</p>
<p><strong><span style="color:#900;">Update:</span></strong><br />
A word about <code>this.form.method='get'</code><br />
Some browsers (we&#8217;re not naming names but you know who you are), can&#8217;t handle the length of the <code>__VIEWSTATE</code> URL parameter which is sent when using the get method. In cases where we have to use the get method for forms, we add the following JavaScript code at the top of our form to clear the <code>__VIEWSTATE</code> value. This is not &#8220;best practices&#8221; but allows the solution above to work when using some &#8220;popular&#8221; browsers.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #006600; font-style: italic;">//&lt;![CDATA[</span>
document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;__VIEWSTATE&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">=</span><span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//]]&gt;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.adammer.com/blog/2009/06/adding-html-form-submission-to-the-texthtml-module-in-dnn/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
