I have a problem when using a hidden field to send a value to the server.
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(objec t 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>Untitl ed Page</title>
<script language=vbscri pt>
function getpicvb()
dim javatext
javatext = document.getEle mentById("File1 ").getAttribute ("value")
dim fso
set FSO = CreateObject("S cripting.FileSy stemObject")
dim drive
set drive =
FSO.GetDrive(FS O.GetDriveName( FSO.GetAbsolute PathName(javate xt)))
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="getpic vb() " type=submit
/>
<asp:Label ID="Label11" Runat="server" Text="Label"></asp:Label>
<input type=hidden id=hide />
</body>
----------------------------------------------------------------------------
------------------------------------------------
"Brock Allen" <ba****@NOSPAMd evelop.com> wrote in message
news:44******** **************@ msnews.microsof t.com...
Make a hidden field (via Page.RegisterHi ddenField) and have the javascript
write the value to the hidden. In the server, fetch the value via Request.Form["YourFieldI D"]
-Brock
DevelopMentor
http://staff.develop.com/ballen
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=javasc ript>
function getpic()
{ string s;
s = document.getEle mentById("File1 ").getAttribute ("value");
<% run(s); %>
}
I think this would be rather common, so maybe I'm missing some basics?
Regards Magnus