Hello!
Now, I've tried to use a hidden field but I can't get it to work.
Below you can see my code in simplyfied versions.
What I'm trying to do is:
1. The user browses for a picture at the network from their computer using
control File1.
2. The user clickes the button Commit picture (with id CliBtn)
a. The script is running at the client to get the sharename of the file
selected
b. The script should update a picture shown (the code below just shows
the label with the path)
c. The code-behind should then save all values in a database.
The problem appear when I'm trying to set the value to the hide control, so
I am doing something wrong.
I'm not so used to web developing, so please give me some help here, with
code please.
Regards Magnus
-------------------------
Code-behind page in C#
-------------------------
void Page_Load(object sender, EventArgs e)
{
HtmlInputHidden hide = new HtmlInputHidden();
hide.ID = "hide";
hide.Value = "Hidden Text";
sURL = Request.Form["hide"].ToString();
Label11.Text = sURL;
}
------------------------
..ASPX page
------------------------
<head>
<title>Untitled Page</title>
<script language=vbscript>
function getpicvb()
dim javatext
javatext = document.getElementById("File1").getAttribute("value")
dim fso
set FSO = CreateObject("Scripting.FileSystemObject")
dim drive
set drive =
FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathName(javatext)))
javatext = drive.ShareName
'hide.value = javatext ' this row doesn't work
alert(javatext)
end function
</script>
</head>
<body>
<input id="File1" type="file" />
<input id="CliBtn" value="Commit picture" onclick="getpicvb() " type=submit
/>
<asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
<input type=hidden id=hide />
</body>
----------------------------------------------------------------------------
------------------------------------------------
Brock Allen said:
Make a hidden field (via Page.RegisterHiddenField) and have the javascript
write the value to the hidden. In the server, fetch the value via Request.Form["YourFieldID"]
Hello!
I have a client javascript that generates a string (like below). This
string should then be used by server code (in this case a function
called run).
<script language=javascript>
function getpic()
{ string s;
s = document.getElementById("File1").getAttribute("value");
<% run(s); %>
}
I think this would be rather common, so maybe I'm missing some basics?
Regards Magnus