Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 21st, 2006, 04:30 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default How do I connect with the page’s JScript?

Given the following:
Code:
<html>
<body>
    <asp:FileUpload ID="FilUpld" runat="server" OnLoad="alert('load');" />

</body>
</html>
I get the error message that “'alert' is not a member of 'ASP.<my_page>_aspx'.” How can I tell an asp control to utilize straight JavaScript commands and statements?

Tried changing to
Code:
<asp:FileUpload ID="FilUpld" runat="server" OnLoad="javascript:alert('load');" />
but got “'javascript' is not a member of 'ASP.<my_page>_aspx'”
 
Old November 28th, 2006, 04:11 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

There’s got to be a way... Anyone?
 
Old November 28th, 2006, 09:04 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there an OnLoad event on the input for type=file?

Woody Z http://www.learntoprogramnow.com
 
Old November 29th, 2006, 04:33 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

There is. Of course, that doesn't mean a lot. I believe the list of choices in a standard HTML control is the same for every control, when the IDE is presenting the IntelliSense choices—I don't think they are control-type specific as is the case with asp: controls.

I added
Code:
    FileUploader.Attributes.Add("onchange", "'TestLoad();'") ' and
    FileUploader.Attributes.Add("onload",   "'TestLoad();'")
    but neither ran TestLoad()...

For an asp:button I find that—nestled in among the other choices—there is OnClientClick.

The OnClick event operates as part of the Submit machinery—it doesn't actually add anything to the HTML-rendered button. The OnClientClick becomes an OnClick entry in the properties of the rendered button.

(I knew there just had to be a way—the JavaScript of a page is just too useful to universally ignore.)

I am essentially writing an HTML wizard, which has 3 panes. In the 1st the user fills in controls to set what to do with the data. When that is configured properly (7 digits in one control, a single letter in the other), the [[u]Next</u>] button is enabled. When they click it, a 2nd <div> is made visible instead, with a [[u]Cancel</u>], a [[u]Back</u>] and a [[u]Next</u>] button (the last of which is disabled), and an FileUpload control. the user having selected a file, I want to enable the 2nd div’s [[u]Next</u>] button.

Suggestions?
 
Old November 29th, 2006, 08:21 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, the html Body, Image, Frame, Link, and a few other elements have an onLoad event (I'm talking client side events here), but I don't think an input element has an onLoad. However, there are events that an input element of type=file has that can be useful to you.

Anyway, it looks like you have found how to hook to client javascript, right? What your first post shows is how to hook up to server side events, not client side. The line:

<asp:FileUpload ID="FilUpld" runat="server" OnLoad="alert('load');" />

is trying to hook you up to a server side method called "alert", and it will call that code when the control is loaded in the flow of the page_load - and that, of course, isn't what you are after. I am sure you know that by now.

So, making the wizard is where you are at. If one of the input/type=file events are useful to you, you need to able to hook up to one of those, if I understand correctly, so that the Next button becomes enabled. So how to do that? The event I recommend you try is the onpropertychange event, which will fire each time you type a character into the field text field, or after selecting a file after clicking the browse button. Note that you could do certain validations as well as enable the Next button. You also have to remember that not all browsers will necessarily deal with these events equally.

Woody Z http://www.learntoprogramnow.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
JScript DumAss HTML Code Clinic 1 August 25th, 2004 02:46 AM
how to debug jscript alyeng2000 ASP.NET 1.x and 2.0 Application Design 4 May 22nd, 2004 05:13 AM
Using JScript with VBScript jwalborn Javascript How-To 4 October 13th, 2003 10:07 AM
JScript Des67 Javascript 1 July 28th, 2003 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.