Need to format table in MVC view to generate PDF - asp.net-mvc

I'm trying to create a pdf and this is my view that generates that PDF, however for some reason the styling and formatting isn't working. I have tried to align text and add css styling but nothing seems to be working. Does anyone have some advice on how I can get the table to display the top row to be one line of information instead of getting cut off and moved under. Here is what the PDF curently looks like; as you can see the row doesn't look right. I need that row to be one single line flowing together. Any advice would be greatly appreciated.
Here is my MVC view that is generating the PDF:
#model List<ArdentMC.DHS.COP.Mobile.MVC.Models.Reports>
#{
Layout = "";
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div style="color:red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>
<table style="width:300px;">
#foreach (var item in Model)
{
<tr>
<td> #item.Phase </td>
<td> #item.NocNumber</td>
<td> #item.Title</td>
<td> #item.Location</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td>#item.ReportDateText</td>
</tr>
}
</table>
#foreach (var item in Model){
#Html.Raw(item.Description)
}
<br /><br /><br /><br /><br />
<br /><br /><br /><br /><br />
<div style="color:black; align:center;">US Department of Homeland Security</div>
<br />
<div style="color:red; align:center;">UNCLASSIFIED/FOR OFFICAL USE ONLY</div>
</body>
</html>

Related

Adding a Add Row button which then adds a new row for Amazon MTurk Form

I have a table set up in Amazon mturk with a single row which the user can fill in with the relevant details. However, sometimes the user will need to fill in two or three more rows of data. I want them to be able to click an "add new row" button and then a new row appears at the bottom of the table which is identical to the row above for them to fill in.
I tried looking at another task to see how they got the add row button to work but I can't figure out how they did it https://worker.mturk.com/projects/3PP5EK5QU1Q6PKONUENX4D1ESGSUNM/tasks?ref=w_pl_prvw
When I include their code of <input data-action ... it gives me an error saying the name is not defined
<!-- You must include this JavaScript file -->
<script src="https://assets.crowd.aws/crowd-html-elements.js"></script
<!-- For the full list of available Crowd HTML Elements and their input/output documentation,
please refer to https://docs.aws.amazon.com/sagemaker/latest/dg/sms-ui-template-reference.html -->
<!-- You must include crowd-form so that your task submits answers to MTurk -->
<crowd-form answer-format="flatten-objects">
<div>
<strong>Instructions: </strong>
<span>XX</span>
<div>
<div>
<p>Link to the Website: URL </p>
<p>City: "${City}"</p>
</div>
<div>
<table>
<tr>
<th>Plan Name</th>
<th>Price</th>
<th>Internet Quota (GB)</th>
<th>Local Quota (GB)</th>
<th>Other Quota</th>
</tr>
<tr>
<td>
<form>
<crowd-input name="Plan" placeholder="e.g. InternetMAX 4.5GB" required></crowd-input>
</form>
</td>
<td>
<form>
<crowd-input name="Price (Rp)" placeholder="e.g. 42000" required></crowd-input>
</form>
</td>
<td>
<form>
<crowd-input name="Internet Quota GB" placeholder="e.g. 0.5" required></crowd-input>
</form>
</td>
<td>
<form>
<crowd-input name="Local Quota GB" placeholder="e.g. 2" required></crowd-input>
</form>
</td>
<td>
<form>
<crowd-input name="Other Quota GB" placeholder="e.g. 0.5" required></crowd-input>
</form>
</td>
<td>
<input data-action="more-items" type="button" value="Add Items">
</td>
</tr>
</table>
</div>
</div>
</div>
```
``

The page is validated automatically after I set a validator and every time I want to redirect to another page, I get the error from validator?

I though I have finished working on the page, however, after another round of checking, it seems that the previous working link is not working anymore and every time when clicked, tries to validate the page.
The link is a part of a main master page.
Looks like the Post Back event called from the clicking on the link is trying to validate Date Pickers again.
I have the following logic to build CustomValidator and RadGrid, where I validates RadDatePickers:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
<div align="center">
<asp:CustomValidator ID="checkForTwoDates" ClientValidationFunction="AtLeastOneDate_ClientValidate" ViewStateMode="Enabled"
EnableClientScript="True" ErrorMessage="At least one date should be selected" runat="server"></asp:CustomValidator>
<table class="moss2Search">
<tr>
<td>
<div runat="server">
<telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker1" width="100%" runat="server" DateInput-Label="Boarding Start Date"></telerik:RadDatePicker>
</div>
</td>
<td>
<div runat="server">
<telerik:RadDatePicker RenderMode="Lightweight" ID="RadDatePicker2" width="100%" runat="server" DateInput-Label="Boarding End Date">
</telerik:RadDatePicker>
</div>
</td>
<td>
<div>
<asp:CheckBox ID="chkMerActive" runat="server" Checked="true"/>Active
</div>
</td>
<td>
<telerik:RadButton RenderMode="Lightweight" runat="server" Text="Search" ID="Button1" OnClick="btnSearch_Click"></telerik:RadButton>
</td>
</tr>
</table>
</div>
</telerik:RadAjaxPanel>
<asp:Label ID="lblMsg" ForeColor="red" runat="server"></asp:Label>
<br />
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ajaxControl">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ajaxUpdateControl"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<div>
<telerik:RadGrid RenderMode="Lightweight" runat="server" ID="grdMoss2Merchants" AllowPaging="True" AllowSorting="true" PagerStyle-AlwaysVisible="true" OnNeedDataSource="BindToDatasource">
<ExportSettings IgnorePaging="true">
<Excel WorksheetName="Moss2Merchants" />
</ExportSettings>
</telerik:RadGrid>
</div>
What am I doing wrong or missing?

Dojo - Upload two files in one Form

I use Dojo and want to send two files and one String to a REST Service. The HTML for that is the following:
//...
<script>
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.CheckBox");
dojo.require("dojox.form.Uploader");
dojo.require("dojox.embed.Flash");
if(dojox.embed.Flash.available){
dojo.require("dojox.form.uploader.plugins.Flash");
}else{
dojo.require("dojox.form.uploader.plugins.IFrame");
}
</script>
//..
<form action="http://localhost:8080/service" enctype="multipart/form-data" method="POST" name="inputDataForm" id="inputDataForm">
<table border="1" cellpadding="1" cellspacing="1" height="88" width="925">
<tbody>
<tr>
<td>Dataset1</td>
<td><input name="train" type="file" value="Browse" data-dojo-type="dojox/form/Uploader"/></td>
</tr>
<tr>
<td>Dataset2</td>
<td><input name="test" type="file" value="Browse" data-dojo-type="dojox/form/Uploader"/></td>
</tr>
<tr>
<td>Number of Customers</td>
<td><input name="numberCustomers" size="40" type="text" data-dojo-type="dijit/form/TextBox" /></td>
</tr>
</tbody>
</table>
<p><input name="runButton" type="submit" value="Run" data-dojo-type="dijit/form/Button" id="submitButton" /></p>
</form>
However: If I press the submit button, I can see via Firebug that there are sent TWO POST-Requests. One with the first file and the "Number of Customers" field and one with the second file and the "Number of Customers" field. However, my REST Service wants to have both files and the "Number of Customers" fields in one POST Request. How can i do that? What am I doing wrong?
Thanks a lot in advance
Natan

want to parse href in ruby on rails using nokogiri

I am using nokogiri as my HTML parser.
<html>
<body>
<form>
<table>
<tr><td>Some Text</td></tr>
<tr>
<td colspan="2" align="center">
<br />
<a href="TransportRoom?servlet=CaseSearch.jsp&advancedSearch=Advanced">
Advanced Search
</a>
<br />
</td>
</tr>
</table>
</form>
</body>
</html>
In this html code I want to parse the "Advance Search" link. This html is saved in variable named doc1
Can anyone help me with this?
Should be as simple as
doc = Nokogiri::HTML(doc1)
href = doc.css("a").first.attr('href')
This is what you want?
First answer is working for me but if there is n number of links than we can manipulate it by this way
html = Nokogiri::HTML(doc1)
html.css("a").each do |element|
if (element.text.strip == 'Advanced Search')
advance_search_link = element.attr('href')
end
end
I would do as below :
require 'nokogiri'
#doc = Nokogiri.HTML <<-eotl
<html>
<body>
<form>
<table>
<tr><td>Some Text</td></tr>
<tr>
<td colspan="2" align="center">
<br />
<a href="TransportRoom?servlet=CaseSearch.jsp&advancedSearch=Advanced">
Advanced Search
</a>
<br />
</td>
</tr>
</table>
</form>
</body>
</html>
eotl
#doc.at_xpath("//a[normalize-space(.)='Advanced Search']")['href']
# => "TransportRoom?servlet=CaseSearch.jsp&advancedSearch=Advanced"

reading from a file using the input type=file in grails

Hi I have the following code in my grails gsp
<form action="upload-script-url" method="post" enctype="multipart/form-data">
<table class="table"style="width: 75%">
<tr>
<td>
<span style="font-weight: bold; ">Select the Source File:</span>
<input size="75" type="file" id="payload" name="payload"/>
</td>
</tr>
<tr>
<td>
<input type="submit" class="red" id="Run">Run</button>
</td>
</tr>
</table>
</form>
I read the form parameters from: here
Are those right parameters in the html form?
Now how should I proceed to read the data from the selected file? do I have to use the apache commons fileupload api ?
Thanks
request.getFile("payload")
and you will get a CommonsMultipartFile
If you take some time to (again) actually look at the documentation you will see how to do it...

Resources