I am building a document catalogue in Dreamweaver CS6 using asp VB Script and Access as my DB. I have a "documents" table with attributes of
-refid (PK) .........(this is an auto#)
-docname ...........(Description of the doc)
-location ..............(e.g. "images\Power Point\Smart-Wireless-Overview-16x9.pptx")
-typeid (FK).......(e.g. Manual, Presentation, Drawing etc)
-modelcode.........(e.g. 3051S, 3144 etc)
I am building a search field where the user can enter a search criteria and the system should display the document.
I was able to design the search and get accurate results however I am unable to get a clickable link for the user to view or download the document. All that is appearing on the browser is the actual link stored in the DB.
Is there any way for me to get a link or icon for the user to click to view the document?
------SEARCH CODE------
<h2>Select A Search Criteria</h2>
<div id="search_options">
<form name="form1" method="post" action="Result.asp">
<label for="input"></label>
<input type="text" name="input" id="input">
<input type="submit" name="search_btn" id="search_btn" value="Submit">
</form>
</div>
------RESULTS CODE------
<h2>Content Found</h2>
<div id="results">Content for id "results" Goes Here
<% If Not Search.EOF Or Not Search.BOF Then %>
<table border="1">
<tr>
<td>refid</td>
<td>docname</td>
<td>location</td>
<td>typeid</td>
<td>modelcode</td>
<td>Details</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT Search.EOF)) %>
<tr>
<td><%=(Search.Fields.Item("refid").Value)%></td>
<td><%=(Search.Fields.Item("docname").Value)%></td>
<td><%=(Search.Fields.Item("location").Value)%></td>
<td><%=(Search.Fields.Item("typeid").Value)%></td>
<td><%=(Search.Fields.Item("modelcode").Value)%></td>
<td> View</td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Search.MoveNext()
Wend
%>
</table>
<% End If ' end Not Search.EOF Or NOT Search.BOF %>
</div>
</section>
-----DETAILS CODE-----
<p>Content for id "results" Goes Here</p>
<p><img src="images/Data_Sheets/00813-0100-4001.pdf" width="82" height="73" longdesc="<%=(Details.Fields.Item("location").Value)%>"></p>
<p><%=(Details.Fields.Item("location").Value)%></p>
</div>
</section>
Related
What i have to create is a form that i migrated out of access. I created the 4 asp pages. Now what they would like is to store the user input values some how until they hit the final page before writing to the SQL database. What is the easiest way to store this data until the final page for submission? I could try an array or maybe even java script?
You could use the session object - http://msdn.microsoft.com/en-us/library/ms525095(v=vs.90).aspx
As suggested in this other answer, you could use session variables. The alternative is to just pass them from page to page using hidden form fields, eg
<input name="yourvariable" type="hidden" value="<%=Request.Form("yourvariable")%>
There's no correct answer, it's a case of which you're most comfortable with
"get_user_info.asp"
<html>
<head></head>
<body>
<form id='frm_user_info' name='frm_user_info' method='post' action='get_user_info_go.asp'>
<table cellspacing='3'>
<tr>
<td align=right>Name</td>
<td><input type='text' id='s_name' name='s_name' size='40'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' value='Next'></td>
</tr>
</table>
</form>
</body>
</html>
"get_user_info_go.asp"
<%
s_name=request.form("s_name")
if (s_name="") then response.redirect("get_user_info.asp")
session("s_name")=s_name
response.redirect("next_page.asp")
%>
I'm using the form tag.
<form:form commandName="foo">
<div class="myclass ">
<label>Foo</label>
<form:input path="fooName"/>
</div>
<div class="controls">
<input type="submit" class="btn" value="Submit"/>
</div>
</form:form>
Question
Is there a way to find out if an error happened on a specific field?
I am aware of the <form:erros path="fooName"/> but this will print out the error message. I am after something that simply returns true or false based on if the error happened on fooName property. I need this because if the error happened then I can insert the css class error next to my class
Yes, it is possible:
<%# taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%# taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<form:form commandName="foo">
<spring:bind path="fooName">
<div class="myclass ${status.error ? 'error' : ''}">
<label>Foo</label>
<form:input path="fooName"/>
</div>
</spring:bind>
<div class="controls">
<input type="submit" class="btn" value="Submit"/>
</div>
</form:form>
When you enclose field inside <spring:bind> tag you have access to implicit variable status of type BindStatus. You may use it to check that field has error or not.
You also probaly find useful following links:
Spring MVC and Twitter Bootstrap – customizing the input fields
Spring MVC + Bootstrap Errors (extended)
Here is another way with <spring:hasBindErrors> (inside it you have access to errors variable of type Errors) which will work only in environment with JSP 2.2:
<spring:hasBindErrors name="foo">
<div class="myclass ${errors.hasFieldErrors('fooName') ? 'error' : ''}">
<label>Foo</label>
<form:input path="fooName"/>
</div>
</spring:hasBindErrors>
I have an asp:RadioButtonList named rblDependants
which renders as follows and a panel pnlDependants and I need to hide it when radio button selection is "No" and show it when its "Yes". I have tried a few snippets from the forums and none seem to work fine. Can anyone help me pls....!
<table id="ctl00_ContentPlaceHolder1_ctl02_rblDependants" border="0" style="border-width:0px;">
<tr>
<td><input id="ctl00_ContentPlaceHolder1_ctl02_rblDependants_0" type="radio" name="ctl00$ContentPlaceHolder1$ctl02$rblDependants" value="Yes" /><label for="ctl00_ContentPlaceHolder1_ctl02_rblDependants_0">Yes</label></td>
</tr><tr>
<td><input id="ctl00_ContentPlaceHolder1_ctl02_rblDependants_1" type="radio" name="ctl00$ContentPlaceHolder1$ctl02$rblDependants" value="No" checked="checked" /><label for="ctl00_ContentPlaceHolder1_ctl02_rblDependants_1">No</label></td>
</tr>
</table>
<div id="ctl00_ContentPlaceHolder1_ctl02_pnlDependants">
<div class="QuestionWrapper">
<div class="Question">
<label for="">No. of Dependants</label>
</div>
<div class="Answer">
<input name="ctl00$ContentPlaceHolder1$ctl02$txtNoOfDependants" type="text" maxlength="2" id="ctl00_ContentPlaceHolder1_ctl02_txtNoOfDependants" />
</div>
<div class="ClearFloat"></div>
</div>
Something like this should work:
$("table[id$=_rblDependants] :radio").change(function() {
$(this).closest('table').next().toggle(this.checked && this.value == 'Yes');
}).change();
This would work for any number of repeated controls since it finds the <div id="X_pnlDependants"> relatively. All we're doing it taking an <table> who's ID ends-with _rblDependants, taking any :radio buttons inside it and binding to their .change() event. Then either of them is changed it's checking that the result was value="Yes" and it was .checked, if that's the case show the panel, otherwise hide it, via .toggle(bool).
The .closest() and .next() are to go up to the <table> then to the next element, the <div>, since that's what you want to hide/show. The .change() on the end is to trigger the handler initially, so if "No" is initially checked, it hides the <div> on load.
You can give it a try here
I have used MVC MVC 2.0 Client Side validation, but it does not work as expected. Now I am trying to find out, what I did wrong.
How does it work?
I have this rendered form:
<form method="post" action="/Sprint/Edit/68d4886b-a86a-4f0b-b713-39219febddf3">
<fieldset>
<legend>Sprint</legend>
<table>
<tbody><tr>
<td><label for="sprint_Title">Title</label></td>
<td><input type="text" value="Wichtige Private Erledigungen" name="sprint.Title" id="sprint_Title" class="input-box t-input"></td>
<td><span class="error"><span id="sprint_Title_validationMessage" class="field-validation-valid"></span></span></td>
</tr>
<tr>
<td><label for="sprint_Date">Date</label></td>
<td>
<div id="sprint_Date" class="date-picker t-input t-widget t-datepicker"><input value="12.05.2010" name="sprint.Date" id="sprint_Date-input" class="t-input" autocomplete="off"><a title="Open the calendar" tabindex="-1" href="#" class="t-link t-icon t-icon-calendar">select date</a></div>
</td>
<td><span class="error"><span id="sprint_Date_validationMessage" class="field-validation-valid"></span></span></td>
</tr>
<tr>
<td><label for="sprint_Description">Description</label></td>
<td><textarea rows="10" name="sprint.Description" id="sprint_Description" cols="80" class="t-input">dsfs1</textarea></td>
<td><span class="error"><span id="sprint_Description_validationMessage" class="field-validation-valid"></span></span></td>
</tr>
</tbody></table>
</fieldset>
<input type="submit" value="Submit" name="Submit" id="Submit" class="t-button t-state-default">
</form>
And this script is rendered:
<script type="text/javascript">
//<![CDATA[
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }
window.mvcClientValidationMetadata.push({"Fields":[{"FieldName":"sprint.Title","ReplaceValidationMessageContents":true,"ValidationMessageId":"sprint_Title_validationMessage","ValidationRules":[{"ErrorMessage":"Title is required.","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"sprint.Date","ReplaceValidationMessageContents":true,"ValidationMessageId":"sprint_Date_validationMessage","ValidationRules":[{"ErrorMessage":"Das Feld \"Date\" ist erforderlich.","ValidationParameters":{},"ValidationType":"required"}]},{"FieldName":"sprint.Description","ReplaceValidationMessageContents":true,"ValidationMessageId":"sprint_Description_validationMessage","ValidationRules":[]}],"FormId":null,"ReplaceValidationSummary":false});
//]]>
</script>
But to my surprise the breakpoint only stops at page load. I think it should be also if a field is tabbed? At least, after I press the post button.
Why does client side validation not work for me?
This just sets up the handlers, it won't actually hit this line when the form is submitted, nor when you tab between fields.
You will get validation errors upon losing focus and/or form submission, however if you have other javascript errors on the page it can cause this to fail.
Also, make sure you've reference the required javascript files in your header:
MicrosoftAjax.js
MicrosoftMvcValidation.js
I am having problems getting my form to Post to my Save method in a controller. I am new to MVC, and have followed several examples to try to get this to work. Here is my html markup:
<form action="Edit/Save" method="post">
<fieldset>
<legend>Personal Information</legend>
<table class="editGrid">
<tr>
<td><label for="txtFirstName">First Name:</label></td>
<td><input type="text" id="txtFirstName" value="<%=user.FirstName %>" name="FirstName" /></td>
</tr>
<tr>
<td><label for="txtLastName">Last Name:</label></td>
<td><input type="text" id="txtLastName" value="<%=user.LastName %>" name="LastName" /></td>
</tr>
<tr>
<td><label for="txtNtLogin">NT Login:</label></td>
<td><input type="text" id="txtNtLogin" value="<%=user.NtLogin %>" name="NtLogin" /></td>
</tr>
<tr>
<td><label for="txtHireDate">Hire Date:</label></td>
<td><input type="text" id="txtHireDate" value="<%=string.Format("{0:d}",user.HireDate) %>" name="HireDate" /></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Job Information</legend>
<table class="editGrid">
<tr>
<td><label for="CostCenters">Cost Center:</label></td>
<td><%=Html.DropDownList("CostCenters")%></td>
</tr>
<tr>
<td><label for="Managers">Manager:</label></td>
<td><%=Html.DropDownList("Managers")%></td>
</tr>
<tr>
<td><label for="Responsibilities">Responsibility:</label></td>
<td><%=Html.DropDownList("Responsibilities")%></td>
</tr>
<tr>
<td><label for="Departments">Department:</label></td>
<td><%=Html.DropDownList("Departments")%></td>
</tr>
<tr>
<td><label for="Active">Active:</label></td>
<td><%=Html.CheckBox("Active",user.Active) %></td>
</tr>
<tr>
<td><label for="txtHireDate">Hire Date:</label></td>
<td><%=Html.TextBox("txtHireDate",string.Format("{0:d}",user.HireDate)) %></td>
</tr>
<tr>
<td><label for="txtReleaseDate">Release Date:</label></td>
<td><%=Html.TextBox("txtReleaseDate",string.Format("{0:d}",user.ReleaseDate)) %></td>
</tr>
</table>
</fieldset>
<input type="submit" value="Save Changes" />
</form>
This form routes to a Save method in my EditController. Here is the code for my EditController's Save method:
public class EditController : Controller
{
public ActionResult Save()
{
//Save code goes here
}
I have tried using the html form tag, and also the Html helper code:
using (Html.BeginForm("Save", "Edit"))
Here is the entry from my RegisterRoutes method in the Global.asax file:
routes.MapRoute("EditSave", "{controller}/Save",
new { controller = "Edit", action = "Save" });
No matter what I do, the submit button does not trigger the Save method. Yet, if I manually key in the Url, The code breaks right into the Save method.
Edit:
Per Craig Stuntz's comment, I checked the source of the page. The page actually contains 2 forms, although only 1 is coded on the page by myself: Here is the HTML that appears prior to my form tag:
<form name="aspnetForm" method="post" action="44" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNjM3OTAyNTUzZGQrHhVn9+t78aHxN0vHvKUJ8DQWlQ==" />
</div>
<div id="nav">
<span id="navLinks">
Placeholder Link
</span>
<span id="userName">
<span id="ctl00_lblUserName" class="UserName">Welcome, Test User</span>
</span>
</div>
<div id="Content">
<div id="formContainer">
<form action="Edit/Save" method="post">
I didn't think MVC generated viewstate or additional form tags. I am pulling data and populating it into this form using another method from the same controller. Am I doing something wrong here?
Ok, got the answer. And thanks Craig for having me look at the HTML again! My master page had generated a form tag in it without my knowing it, so I essentially had nested forms on the same page. After I removed the form from the Master Page, everything worked perfectly.