473,721 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set a value to a hidden field in a web page

Hello!

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



Nov 19 '05 #1
4 3626
Controlled envionement ? What is the exact problme you have (you have always
"Hidden Text" server side ?

In particular fso is not supposed to work without tweaking security
settings. ARe you sure itjust doesn't fails silently...
Also you always change the value of the "hide" field when the page loads...
Try to do not "if (!Ispostback)". ..

Patrice

--

"Magnus Blomberg" <ma************ *@skanska.se> a écrit dans le message de
news:uT******** ******@TK2MSFTN GP09.phx.gbl...
Hello!

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



Nov 19 '05 #2
Magnus what are u trying to do??
Vbscript,C#???? ?

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Hello and thanks for your answer.
Well, I thought fso was not a common way to solve this, but since this is
for a Intranet, I think I can theak the security anyway. If you have a
better solution for this issue I'll be glad to here it.
I'm not sure what silent failure does mean, but I think that is what I get.
I get no error message, but the alert row is never executed when the
hide.value = javatext is run.

The problem does not appear when working with fso. It appears when trying to
set the hide object.

I am familiar to the (!IsPostBack) command, so I will take care of that in
my full code.
My code in this forum is shrinked.

Regards Magnus
"Patrice" <no****@nowhere .com> wrote in message
news:#X******** ******@TK2MSFTN GP14.phx.gbl...
Controlled envionement ? What is the exact problme you have (you have always "Hidden Text" server side ?

In particular fso is not supposed to work without tweaking security
settings. ARe you sure itjust doesn't fails silently...
Also you always change the value of the "hide" field when the page loads... Try to do not "if (!Ispostback)". ..

Patrice

--

"Magnus Blomberg" <ma************ *@skanska.se> a écrit dans le message de
news:uT******** ******@TK2MSFTN GP09.phx.gbl...
Hello!

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
>



Nov 19 '05 #4
Ok, so this line is never executed.

Check if the fso object is set. Do you have yet tweaked security ?

If I remember when security is not tweaked , it fails without any warning
(as anyway it 's not supposed to work).
What do you want to do ? You can use an input type=file to get the name
server side even if you don't want to upload this file. This way you
wouldn't need to copy this value in an hidden field.

Also I don't really see how it works. The server could perhaps not have the
same netwrok path available.

Depneidng on what you wan to do with this file, I would upload it server
file to do the intended processing....

Good luck

Patrice

--

"Magnus Blomberg" <ma************ *@skanska.se> a écrit dans le message de
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello and thanks for your answer.
Well, I thought fso was not a common way to solve this, but since this is
for a Intranet, I think I can theak the security anyway. If you have a
better solution for this issue I'll be glad to here it.
I'm not sure what silent failure does mean, but I think that is what I get. I get no error message, but the alert row is never executed when the
hide.value = javatext is run.

The problem does not appear when working with fso. It appears when trying to set the hide object.

I am familiar to the (!IsPostBack) command, so I will take care of that in
my full code.
My code in this forum is shrinked.

Regards Magnus
"Patrice" <no****@nowhere .com> wrote in message
news:#X******** ******@TK2MSFTN GP14.phx.gbl...
Controlled envionement ? What is the exact problme you have (you have

always
"Hidden Text" server side ?

In particular fso is not supposed to work without tweaking security
settings. ARe you sure itjust doesn't fails silently...
Also you always change the value of the "hide" field when the page

loads...
Try to do not "if (!Ispostback)". ..

Patrice

--

"Magnus Blomberg" <ma************ *@skanska.se> a écrit dans le message de
news:uT******** ******@TK2MSFTN GP09.phx.gbl...
Hello!

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
> >
>
>
>



Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1730
by: Lukelrc | last post by:
Hi all, I have an asp page with a delete button which has an OnClick Ok/Cancel msgbox event. My problem is that in order to run the Onclick event i've chaged the buttons type from "Submit" to "Button" - and now the buttons value (which i need in the next page) is not passed in the URL. This is what i have tried to do:
16
11498
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
6
2748
by: charlie_M | last post by:
I figured out via various help from this forum... EXAMPLE: onClick="document.forms.MYBUTTON.value='SIMPLE';document.forms.submit()" In my CGI I see "MYBUTTON" = "SIMPLE" and this works fine.... except that the element MYBUTTON must exist as a hidden field.
5
1884
by: cmc_dermo | last post by:
I have a form that has a select list. A user chooses a value and the page refreshes showing the selected value in the dropdown box. So I want to use Javascript to get the selected query from the form. I then want to pass it as a hidden field. So for example the section of the page I'm interested in will look like
2
3935
by: Kevin | last post by:
I've got a problem where I need to know the value of a hidden field inside a repeater once a button is clicked. Ths code inside my repeater looks like this: <input id="conf_num" type="hidden" value=<%# trim(Container.DataItem("confirm_num"))%> name="conf_num" runat="server" /> <asp:ImageButton ImageUrl="images/send_conf.gif" OnClick="ConfSend_Click" runat="server" />
1
2609
by: xenophon | last post by:
I add a Hidden form field to my asp.net page in the codebehind, the Value peoperty is set to 0 and EnableViewState is set to true. Then I add a LiteralControl with JavaScript that says to set the value to 1. If I set view the value of th ehidden form field in the debugger during the course of a PostBack, the value is still set to 0. Are there any samples of setting a vlaue with JavaScript and reading the new value in ASP.NET? Thanks.
2
3274
by: xenophon | last post by:
I added a Hidden Form Field to a form in the code behind. The value is being set in JavaScript client-side, but it is not persisting to the server in the PostBack. I know the value is being set properly because it displays in the document.write method. Create a simple page and paste the below in the code-behind (ASP.NET 1.1-SP1) using System;
4
6743
by: Matt | last post by:
I am no JavaScript guru so please bear with me and be as detailed as possible with your response. I thank you in advance. I have an ASP page that contains form elements. I also have an inline frame on this page that contains multiple checkboxes with the same name/id. This is a search form and users need the ability to select which categories they would like to search for. I have to put the categories in an inline frame to save real...
1
4955
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the selection changes to something else then show the field addr_state1. Also the addr_state1 should be hidden when the page loads with value "IN", and if the page loads some other value than show the addr_state1 field. Code used for this is :(I have to...
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.