DNN9 File Upload with <input type='file' /> - dotnetnuke

On DNN 9.6, try to run a custom webform module (built originally on DNN 4.5)
I am trying to upload file
When first navigating to the page, the upload result is always with the postedfile = null
In header/request body, the Content-Type: application/x-www-form-urlencoded; charset=UTF-8
I can see in the request
__ASYNCPOST: true
If try to upload the second time, it will work and with heade/request
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryfzAkNd7yEs3BGnG8
How to get it to full postback at the first time in DNN
<table id="tblUpload" runat="server" cellspacing="0" cellpadding="0">
<tr><td valign="bottom">
<dnn:label id="plPhoto" runat="server" suffix=":" controlname="lnkPreview"></dnn:label>
</td>
<td valign="top">
<input id="filePhoto" type="file" size="50" name="File1" runat="server" />
</td>
</tr>
<tr>
<td valign="bottom"><dnn:label id="plSaveAsFile" runat="server" suffix=":" controlname="txtFileName"></dnn:label></td>
<td>
<asp:textbox id="txtTitle" runat="server" Width="200px" MaxLength="200"></asp:textbox>
<asp:linkbutton CssClass="CommandButton" id="cmdUpload" runat="server" borderstyle="none" text="Upload" resourcekey="cmdUpload"></asp:linkbutton>
<asp:linkbutton class="CommandButton" id="cmdCancel2" runat="server" borderstyle="none" text="Cancel"
resourcekey="cmdCancel" causesvalidation="False"></asp:linkbutton>
</td>
</tr>
</table>

Inside of your manifest for your control, you will have something such as.
<supportsPartialRendering>true</supportsPartialRendering>
Changing this value to "false" is the fasted, and most reliable method to ensure that this is not done via an Async post. There are more advanced ways of doing it, but this is the easiest.

Related

How to show or hide a div in Angular Js

I have implemented two div where i have used some drop down control in a div named as div1 .I want to hide div2 until the any value is selected in drop down.I want to know how to hide or show a div on ng-change or untill any value is selected div2 must not be shown.
Code:-
<div data-ng-app="CustomerNew" data-ng-controller="CreateCustomerCtrl as custom" ng-init="getFormData();">
<div id="div1">
<tr>
<td nowrap>Company Name:
</td>
<td>
<asp:TextBox ID="txtCompanyName" runat="server" CssClass="NormalTextBox" TabIndex="1" Width="160px" Height="10px" ng-model="custom.txtCompanyName" required=""></asp:TextBox>
</td>
</tr>
<tr>
<td>Country:</td>
<td>
<select id="listHomeCountry1" style="width: 182px !important; height: 34px;">
<option value="0">--- Select an option ---</option>
<option data-ng-repeat="Cntry in listHomeCountry" ng-model="custom.listHomeCountry" ng-change="" value="{{Cntry._key}}">{{Cntry._value}}</option>
</select>
</tr>
<div id="div2">
<table style="position: relative; left: 0px;">
<tr align="left">
<td nowrap style="width: 200px">
<asp:Label ID="lblContactAddress1" runat="server" CssClass="NormalTextBox" Width="60%"></asp:Label></td>
<td nowrap>
<asp:TextBox ID="txtContactAddress1" TabIndex="3" Name="txtContactAddress1" runat="server" CssClass="NormalTextBox" Columns="35" Width="160px" Height="10px" ng-model="custom.txtContactAddress1" required=""></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblContactAddress2" runat="server" CssClass="NormalTextBox"></asp:Label></td>
<td>
<asp:TextBox ID="txtContactAddress2" Name="txtContactAddress2" TabIndex="4" runat="server" CssClass="NormalTextBox" Columns="35" Width="160px" Height="10px" ng-model="custom.txtContactAddress2" required=""></asp:TextBox>
</td>
</tr>
</div>
</div>
Now i want untill and unless a value is selected by my dropdown div2 will be hidden.
First assign a variable to your Choice List. For example
<select id="listHomeCountry1" ng-model="homeCounrty">
Then simply use ng-show (doc)
<div id="div2" ng-show="homeCountry">
The above is also equivalent to:
<div id="div2" ng-show="homeCountry != null">

How to send the product data (from table) when "Add to Cart" is clicked to My cart page?

I'm working on a small 'Shopping Site' college project...I had created everything but stucked at one Problem.
There is a content part aligned center in my page where i have a table for Product name,Price and Add to cart in consecutive rows...
<div id="Content">
<table id="ContentTable">
<tr>
<td id="iphone5"><img class="thumbnail" src="mobile_img/iphone-5.jpg"></td>
<td><img class="thumbnail" src="mobile_img/Lumia-920.jpg"> </td>
<td><img class="thumbnail" src="mobile_img/blackberry-curve-9300.jpg"> </td>
<td><img class="thumbnail" src="mobile_img/header.jpg"> </td>
</tr>
<tr>
<td>$ 5767435</td>
<td> $ 2343456</td>
<td> $ 123123</td>
<td>$ 345345</td>
</tr>
<tr class="productdetails">
<td>Add to my cart</td>
<td>Add to my cart</td>
<td>Add to my cart</td>
<td>Add to my cart</td>
</tr>
</table>
</div>
Problem is that, how could i attach product details to 'Add to cart' link below them and send them to other page, which is to be stored in database when 'Add to Cart' below them is clicked...
well you can make a seperate table in database containing the item id,item name or link to the image (or any other way to store images), and the price.
in the page where you want to display, pull the values from the database and put it in a form. so that it would look like:
<form name="something" action="Add_to_Cart.jsp" method="post">
<tr>
<td><input type="checkbox" name="item" value="<%item_id%>"></td>
<td><%Image link/item name 1%></td>
<td><%price 1%></td>
</tr>
<tr>
<td><input type="checkbox" name="item" value="<%item_id%>"></td>
<td><%Image link/item name 2%></td>
<td><%price 2%></td>
</tr>
.
.
.
and finally at the end a submit button with showing Add to Cart..
<input type="submit" name="Getthis" value="Add to Cart"/>
</form>
and then retrive the values like this
String items[]= request.getParameterValues("item");
look for reference: http://www.devmanuals.com/tutorials/java/jsp/multiplecheckbox.html
so now you will have the id's of the item selected and can easily add to cart..
(ps. the codes are just snippets)

Struts2 Checkbox value with Iterator

I am having below code
<s:iterator value="assignedProductRoleBean.serviceProfiles" status="serStatus">
<tr>
<td width="150px">
<s:property value="serviceSpecCode" />
</td>
<s:hidden name="assignedProductRoleBean.serviceProfiles[{#serStatus.index}].serviceSpecCode" value="{serviceSpecCode}" />
<td width="150px">
<s:property value="code" />
</td>
<s:hidden name="assignedProductRoleBean.serviceProfiles[%{#serStatus.index}].code" value="%{code}" />
<td width="50px">
<s:checkbox name="assignedProductRoleBean.serviceProfiles[{#serStatus.index}].granted" value="granted" cssStyle="width:20px;border:0;background-color:transparent" />
</td>
<s:iterator value="assignedProductRoleBean.serviceProfiles[{#serStatus.index}].characteristics" status="serCharStatus">
test
<td width="150px">
<s:property value="key" />
</td>
<s:hidden name="assignedProductRoleBean.serviceProfiles[{#serStatus.index}].characteristics[%{#serCharStatus.index}].key" value="%{key}" />
<td width="150px">
<s:textfield theme="simple" name="assignedProductRoleBean.serviceProfiles[%{#serStatus.index}].characteristics[%{#serCharStatus.index}].value" value="%{value}" /></td>
</s:iterator>
</tr>
</s:iterator>
Problem is, I am getting CHECKED view for true values of 'granted'. however When I uncheck/check in view page, they are not getting updated to respective bean.
One more issue with second iterator (inner). I am having characterstics, though they are not getting displayed in jsp page. however after submitting page, they are coming to action class.
ps i even tried value=%{granted}
I was stuck with the same issue. I've got this working:
<div>
<s:iterator value="podTypeContentList" status="stat" var="podTypeContent">
<s:if test = "#podTypeContent.selected == true">
a
</s:if>
<s:else>
b
</s:else>
<s:property value="%{podContent}" />
<s:property value="%{selected}" />
<s:checkbox name="%{id}" value="%{selected}" fieldValue="%{podContent}" />
<br />
</s:iterator>
<br class="clear" />
<s:submit align="center" value="Save" id="submitButton" cssClass="btn btn-primary" />
</div>
The "selected" is actually isSelected boolean bean property. Threw me off for few hours.

Sending an email in Javascript

can you please let me know
why am unable to send form data to a mail id.below is my code.
And I used this code in Dotnetnuke HTML/TEXT module.
<h3>To join the SoTeC email announcement list, fill out the form below.</h3> <p> </p> <p> </p> <p><style type="text/css"> .link, .signupframe {
color: #226699;
font-family: Arial, Helvetica, sans-serif;
}
.link {
text-decoration: none;
}
.signupframe {
border: 1px solid #000000;
background: #ffffff;
}</style></p> <form id="icpsignup12374" method="post" action="mailto:your#domian.com" onsubmit="return verifyRequired12374();" accept-charset="UTF-8" name="icpsignup">
<input type="hidden" name="redirect" value="http://www.icontact.com/www/signup/thanks.html" /> <input type="hidden" name="errorredirect" value="http://www.icontact.com/www/signup/error.html" />
<div id="SignUp">
<table class="signupframe" border="0" cellspacing="0" cellpadding="5" width="260">
<tbody>
<tr>
<td valign="top" align="right"><font size="2">First Name</font></td>
<td align="left"><input name="fields_fname" type="text" /></td>
</tr>
<tr>
<td valign="top" align="right"><font size="2">Last Name</font></td>
<td align="left"><input name="fields_lname" type="text" /></td>
</tr>
<tr>
<td valign="top" align="right"><font size="1" face="Arial,Helvetica, sans-serif">*</font> <font size="2">Email</font></td>
<td align="left"><input name="fields_email" type="text" /></td>
</tr>
<tr>
<td> </td>
<td><font size="1">*</font><font size="2"> = Required Field</font></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</div> </form> <script type="text/javascript"> var icpForm12374 = document.getElementById('icpsignup12374'); if (document.location.protocol === "https:")
icpForm12374.action ="mailto:your#domian.com"; function verifyRequired12374() { if (icpForm12374["fields_email"].value == "") {
icpForm12374["fields_email"].focus();
alert("The Email field is required.");
return false; }
return true; } </script> <p><a class="link" href="http://www.icontact.com"><font size="2">Email Marketing You Can Trust</font></a></p>
**
Because nested forms aren't allowed. DNN is an ASP.NET WebForms Application and as such already wraps everything in a form. When you add your form to the Text/HTML module, that code is placed within the already existing form and that's not allowed. You have a few options:
1) You can place your form code in an HTML file and then reference that file in an IFrame.
2) You can recreate the form using one of the many DNN Form Modules out there. The core includes the Form and List module that works for basic forms. There are many other Forms modules varying complexity available.
3) You can create a new custom module that recreates the form and does the post using AJAX.
It looks like our mailing list subscribe module might do what you need with some slight modifications. - http://www.efficionconsulting.com/dotnetnuke/modules/mailing-list-subscribe.aspx

IE7 cuts-off input fields in a form

All other browsers, including IE8, render the form correctly, except IE7; I assume IE6 exibits same problem.
IE7 cuts-off, shrinks the form, and shows about 5% of the input fields;
I removed all css formatting but not change; I have applied several related fixes without success; help or direction as to where to find related information or know fixes is welcome since it has consumed much time without success; thanks;
html is included below;
<pre>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>IMM log-in</title>
</head>
<body>
<form method="post" name="form" id="form" action="/imm/login.htm" style=
"font-family:arial;font-size:9pt;padding:5px;table.horizontal-align:left;display:inline;">
<table>
<tbody>
<tr>
<td>
<table>
<tbody>
<tr>
<td><label>log-in ID</label><span class="required">*</span></td>
<td align="left">
<input type="text" name="name" id="form_name" value="" size=
"20" style="width:100%;" />
</td>
</tr>
<tr>
<td align="left"><label>password</label><span class="required">*</span></td>
<td align="left">
<input type="password" name="password" id="form_password"
value="" size="20" style="width:100%;" />
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="left">
<table class="buttons" id="form-buttons">
<tbody>
<tr class="buttons">
<td class="buttons"><input type="submit" name="ok" id="form_ok" value=
" OK " /></td>
<td class="buttons"><input type="submit" name="cancel" id="form_cancel"
value="Cancel" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
</pre>
Found a solution for this thing position:relative

Resources