newbie - simple passing of parameter to function problem

S

Steve

I have the following function in my .net page

<script language=javascript>
function selectFile(fileUrl)
{
if(navigator.appName.indexOf('Microsoft')!=-1)
window.returnValue=fileUrl;
else
window.opener.setAssetValue(fileUrl);
self.close();
}
</script>

and the following code in the page

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<input id="Button1" type="button" value="button"
onclick="selectFile('textbox1value')"/>

I want the user entry in TextBox1 to be sent as the parameter of the
selectFile function for the onclick event of the button.

i.e. for the user to enter something into TextBox1, and then to click
on the button. The text he enters into TextBox1 will be used for the
Parameter of the selectFile function.
 
V

VK

Steve said:
I have the following function in my .net page

<script language=javascript>
function selectFile(fileUrl)
{
if(navigator.appName.indexOf('Microsoft')!=-1)
window.returnValue=fileUrl;
else
window.opener.setAssetValue(fileUrl);
self.close();
}
</script>

and the following code in the page

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<input id="Button1" type="button" value="button"
onclick="selectFile('textbox1value')"/>

I want the user entry in TextBox1 to be sent as the parameter of the
selectFile function for the onclick event of the button.

i.e. for the user to enter something into TextBox1, and then to click
on the button. The text he enters into TextBox1 will be used for the
Parameter of the selectFile function.

....
....onclick="selectFile(this.form.TextBox1.value)"...
....
 
T

Thomas 'PointedEars' Lahn

Server-side code is of little value when discussing client-side scripting.
^^^^^^^^^^^^[1] ^^^^^^^^^^^^^^[2]

[1] Your button probably does not need an ID.
[2] The button's caption should be meaningful.
^^^^^^^[1] ^[2]

[1] The button will not work without client-side script support,
so you should generate it with client-side script.
[2] IE does not support XHTML (yet).
...
...onclick="selectFile(this.form.TextBox1.value)"...
...

... onclick="selectFile(this.form.elements['TextBox1'].value)" ...


PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 2/7/2006 5:17 PM:
...
...onclick="selectFile(this.form.TextBox1.value)"...
...

... onclick="selectFile(this.form.elements['TextBox1'].value)" ...

Either is acceptable and proper.
 
S

Steve

Thank you everyone for your replies.

I have tried both methods but with either one keep getting the error:

is null or not an object this.form.TextBox1.value

or

is null or not an object this.form.elements['TextBox1'].value
 
S

Steve

ok when I remove the .net tags it works perfectly

i.e. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> doesn't
work

but

<input id="TextBox1" type="text" /> works

I wonder if there is a way of making the .net tag textbox work. That
would be much more useful.
 
T

Thomas 'PointedEars' Lahn

Steve said:
ok when I remove the .net tags it works perfectly

i.e. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> doesn't
work

but

<input id="TextBox1" type="text" /> works

As I said, you should omit the `/' and should not serve XHTML to IE.
I wonder if there is a way of making the .net tag textbox work. That
would be much more useful.

I wonder what the ".net tags" generate. For _that_ is what can be accessed
with client-side scripting.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top