Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server-side script with input parameter from Client-side script

Reply
Thread Tools

Server-side script with input parameter from Client-side script

 
 
Magnus Blomberg
Guest
Posts: n/a
 
      04-12-2005
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("val ue");
<% run(s); %>
}

I think this would be rather common, so maybe I'm missing some basics?
Regards Magnus
 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      04-12-2005
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"]

-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=javascript>
> function getpic()
> { string s;
> s = document.getElementById("File1").getAttribute("val ue");
> <% run(s); %>
> }
> I think this would be rather common, so maybe I'm missing some basics?
> Regards Magnus
>




 
Reply With Quote
 
 
 
 
Magnus Blomberg
Guest
Posts: n/a
 
      04-14-2005
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("val ue")
dim fso
set FSO = CreateObject("Scripting.FileSystemObject")
dim drive
set drive =
FSO.GetDrive(FSO.GetDriveName(FSO.GetAbsolutePathN ame(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" <> wrote in message
news: ...
> 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"]
>
> -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=javascript>
> > function getpic()
> > { string s;
> > s = document.getElementById("File1").getAttribute("val ue");
> > <% run(s); %>
> > }
> > I think this would be rather common, so maybe I'm missing some basics?
> > Regards Magnus
> >

>
>
>



 
Reply With Quote
 
Magnus Blomberg
Guest
Posts: n/a
 
      04-14-2005
This question has a new node with Subject "Set a value to a hidden field in
a web page"
/Magnus


"Brock Allen" <> wrote in message
news: ...
> 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"]
>
> -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=javascript>
> > function getpic()
> > { string s;
> > s = document.getElementById("File1").getAttribute("val ue");
> > <% run(s); %>
> > }
> > I think this would be rather common, so maybe I'm missing some basics?
> > Regards Magnus
> >

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameter to function not expecting parameter Mister B C Programming 8 08-26-2010 08:01 AM
decltype as a template parameter when containing reference to anothertemplate parameter. Isti C++ 2 04-19-2010 10:01 PM
without declare parameter [double square(parameter)] return 0 in main WanHongbin@gmail.com C Programming 5 10-01-2008 03:31 AM
Using declaration inside first template parameter as default valuefor second template parameter. Stuart Redmann C++ 5 12-14-2007 08:42 AM
Parameter List / Parameter Block / Anything patterns... mast2as@yahoo.com C++ 4 03-29-2007 09:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57