I am trying to upload a image into a folder using classic asp. I am able to upload image into a folder but not getting the values of other input fields.
<%# Language="VBScript" %>
<!--<span class="code-comment"> #include file="vbsUpload.asp" </span>-->
<form method=post
enctype="multipart/form-data"
action=<%=request.servervariables("script_name")%>>
Your File:<BR><input type="file" name="YourFile"><BR>
<input type="text" name="myname" id="name12">
<BR>
<input type="submit" name="submit" value="Upload">
</form>
<% Dim objUpload, lngLoop, cia
If Request.TotalBytes > 0 Then
Set objUpload = New vbsUpload
For lngLoop = 0 to objUpload.Files.Count - 1
'If accessing this page annonymously,
'the internet guest account must have
'write permission to the path below.
objUpload.Files.Item(lngLoop).Save "c:\inetpub\wwwroot\puntoseguro\admin\image\"
Response.Write "File Uploaded"
Next
cia = Upload.Form("myname")
End if
%>
When I submit the form, I am getting the following error,
File Uploaded
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/admin/test.asp, line 26
line 26 - cia = Upload.Form("myname")
I see two problems with your code.
1) You are declaring the text box like this:
<input type="text" name="myname" id="name12">
But you are trying to get it's value using the ID (name12), but you you need to get it using it's "name" (myname).
2) Also, you should be using objUpload.Form instead of Upload.Form as Upload doesn't appear to exist, hence the error.
You can fix both problems by replacing this line...
cia = Upload.Form("name12")
...with...
cia = objUpload.Form("myname")
(or change the name to match the ID)
Related
I'm working on a Projekt where you can add workers to projects with their ids.I am using springboot, thymeleaf and a database means you give a project and a worker Id and the programm adds the worker to the project.workerlist. The Problem ist that I get this error:
Required request parameter 'projektId' for method parameter type String is not present
My HTML Form looks like this
<form action="#" th:action="#{neuenMitarbeiterzuProjektHinzufuegen}" method="post">
Projekt ID: <input type="text" th:value="*{projektId}" required/><br>
Mitarbeiter ID: <input type="text" th:value="*{mitarbeiterId}" required/><br>
<br>
<input type="submit" value="Mitarbeiter hinzufügen"/>
<input type="reset" value="Clear"/>
</form>
My Post Route Handler Method looks like this
#PostMapping(value="/neuenMitarbeiterzuProjektHinzufuegen")
public String neuenMitarbeiterzuProjektHinzufuegen(#RequestAttribute(value = "projektId") String projektID, #RequestAttribute(value = "mitarbeiterId") String mitarbeiterID,Model m)
{
Optional<Projekt> projekt = projektRepository.findById(Long.parseLong(projektID));
projektRepository.findById(Long.parseLong(projektID)).get().mitarbeiterHinzufuegen(mitarbeiterRepository.findById(Long.parseLong(mitarbeiterID)).get());
return "redirect:Projekte";
}
Looking at your code example I think you should be using #RequestParam not #RequestAttribute. Param is for things posted from the user (web) side and attribute you can set on the server side.
This blog has some explanation on the difference of #RequestAttribute https://www.logicbig.com/tutorials/spring-framework/spring-web-mvc/request-attribute.html
I want my vb6 program to check radio option and submit it through a PHP page. I have the following code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If WebBrowser1.LocationURL = "http://xx.xxxxxxxxxx.com/vb6.php" Then
WebBrowser1.Document.frmC.cid.Value = "52821558"
WebBrowser1.Document.frmC.instrument.Value = "CL"
'WebBrowser1.Document.frmC.ctype
WebBrowser1.Document.frmC.Submit.Click
End If
End Sub
"ctype" in the code above represents the name of the radio option and bellow its HTML code
<INPUT TYPE="Radio" Name="ctype" value="Buy"><span style="font-size: 14px">Buy</span>
<INPUT TYPE="Radio" Name="ctype" value="Sell"><span style="font-size: 14px">Sell</span>
Use SetAttribute:
Dim radio As Object
Set radio = WebBrowser1.Document.frmC.ctype.Item(0)
radio.SetAttribute "checked", "checked"
Use .Item(0) for the first radio & .Item(1) for the second.
When I inspected my page in chrome, I get this:
<input class="form-control form-text required" title="" data-toggle="tooltip" type="text" id="edit-name" name="name" value="" size="60" maxlength="60" data-original-title="Enter your username.">
1.
I right clicked on this code and selected Copy > Xpath. I got this:
//*[#id="edit-name"]
I created a variable:
final By userNameField = By.xpath ("//*[#id="edit-name"]");
I get syntax error.
2.
Then I tried this by id
public void enterUserName(){
driver.findElement(By.id("edit-name")).sendKeys("admin");
System.out.println("User name is entered");
}
It entered the user name just fine. How do I find the correct xpath in chrome so I can create a variable like I tried in step 1?
final By userNameField = By.xpath ("//*[#id="edit-name"]");
You've got double quotes inside your quotes.
change to:
final By userNameField = By.xpath ("//*[#id='edit-name']");
I have a question.
I am learning classic ASP today for my next project. I am currently a .NET developer and using ASP.NET on that project is not a requirement of my client.
I have below a login page script.
Default.asp
<form method="post" action="ASP/aspLogin.asp">
form code here...
<input type="submit" class="Button Is_Default" value="Login"></input>
</form>
Now, what I have in my test ASP/aspLogin.asp page is as follows:
ASP/aspLogin.asp
<%# Language="VBScript" %>
<%
Dim strUsername
Dim strPassword
strUsername = Request.Form("txtUsername")
strPassword = Request.Form("txtPassword")
If strUsername <> "" And strPassword <> "" Then
Response.Redirect("Index.asp")
End If
%>
When I ran the scripts above, the browser just redirected me to ASP/aspLogin.asp. I would want to redirect the user to his respective home page.
My objective is that I want my ASP/aspLogin.asp file do the processing of my form instead of placing the process above the Default.asp page. May I know if I missed something out here or there are some more things to consider to create the code I need. Resources would be also appreciated.
If you have users logging in and out then I'd use session variables (which I'm sure you've encountered in .net), so something along the lines of.
If strUsername <> "" And strPassword <> "" Then
Session("Username") = strUsername
Response.Redirect("Index.asp")
End If
You would then be able to add logic to index.asp and any other page to display data depending on the value of Session("Username").
This code demonstrates the concept. Obviously you would need to ensure that usernames aren't duplicated. In practice I'd recommend a database query to retrieve the primary key value of the users record which corresponds to both username and password
Edit.
So you're basically trying to emulate .net with Classic ASP. Two things to remember. Classic doesn't have code behinds, and a .net webform can only be posted to itself, (which gets really frustrating for someone moving from Classic to .net)
Probably you're best option is to have your form page post to itself and put your processing code at the top of Default.asp, with logic which only triggers it if there's a form submission, ie
<%# Language="VBScript" %>
<%
Dim strUsername
Dim strPassword
strUsername = Request.Form("txtUsername")
strPassword = Request.Form("txtPassword")
If strUsername <> "" And strPassword <> "" Then
'Your processing code
Response.Redirect("Index.asp")
End If
%>
<html>
<body>
<form method="post">
form code here...
<input type="submit" class="Button Is_Default" value="Login"></input>
</form>
</body></html>
An extension of this method would be to use asplogin.asp as an include. (You would need to remove the <%# Language="VBScript" %> from the top of asplogin.asp, as it would become the middle of a page and you would already have your declaration in default.asp). Default.asp would then look like this.
<%# Language="VBScript" %>
<!--#include file="ASP/aspLogin.asp"-->
<html>
<body>
<form method="post">
form code here...
<input type="submit" class="Button Is_Default" value="Login"></input>
</form>
</body></html>
This is about as close as you can get to having a codebehind in Classic
I'm building my first custom editor template for a text area control. My code so far is -
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%= Html.TextAreaFor( Model => Model , 2, 30,
new { #class = "html", #placeholder = ViewData.ModelMetadata.Watermark }) %>
It's not much so far, but it does work. But we need to add a character counter field to show remaining number of characters that the user can type in. I know how to do all the JavaScript to make this work.
So to keep naming system same, I'm going to add a control named ".charCounter" to display number of remaining characters left. My problem is that I cannot figure out the correct syntax to be able to retrieve the field name for the model.
The final version will look something like (JavaScript omitted) -
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%= Html.TextAreaFor( Model => Model , 2, 30,
new { #class = "html", #placeholder = ViewData.ModelMetadata.Watermark }) %>
<span class="xxx">Remaining characters -
<input readonly type="text" name="<fieldName>.charCounter" />
</span>
You could use ViewData.TemplateInfo.HtmlFieldPrefix, like this:
<input
readonly="readonly"
type="text"
name="<%= ViewData.TemplateInfo.HtmlFieldPrefix %>.charCounter"
/>
I ran into an issue where the PropertyName wasn't returning the Model prefix eg Contact.FirstName. I was able to have it return the HTML field Id using this:
#ViewData.TemplateInfo.GetFullHtmlFieldId("")
Returns:
Contact_FirstName
Respectively you can return the field name using:
#ViewData.TemplateInfo.GetFullHtmlFieldName("")
Returns:
Contact.FirstName
ViewData.ModelMetadata.PropertyName works nicely in MVC3.
In razor:
<input readonly="readonly" type="text" name="#ViewData.ModelMetadata.PropertyName">
Getting just the model name/Id (e.g BirthDate):
ViewData.ModelMetadata.PropertyName;
Getting the model name with prefixes for complex objects (e.g Identity.Person.BirthDate):
#Html.NameFor(m => Model);
or
ViewData.TemplateInfo.HtmlFieldPrefix;
Getting the model Id with prefixes for complex objects (e.g Identity_Person_BirthDate):
#Html.IdFor(m => Model)
or
#Html.IdForModel()