Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > .js files

Reply
Thread Tools

.js files

 
 
Mantorok
Guest
Posts: n/a
 
      09-02-2005
Hi all

I want to seperate my client-side validation into a seperate js file,
unfortunately the .js functions have no concept of document.getElementById,
is it possible to have external javascript files referencing page controls?

Thanks
Kev


 
Reply With Quote
 
 
 
 
=?Utf-8?B?V2FqYWhhdCBBYmJhcw==?=
Guest
Posts: n/a
 
      09-02-2005
Hi Kev,

Yes you can define a separate javascript validation file for your
application. By default every .net web application, access the validaiton
file resided in the asp_net_client directory of your wwwroot. But if you want
to write your own js file , you can do that, once you define, all your
validation methods call will forward to that file.

What you have to do is to define a property in the web config file.

<system.web>
<webControls clientScriptsLocation="/script_files/"/>
</system.web>

And now place the WebUIValidation.js in the script_files folder,


--
Wajahat Abbas

http://www.wajahatabbas.com
http://www.dotnetpakistan.com




"Mantorok" wrote:

> Hi all
>
> I want to seperate my client-side validation into a seperate js file,
> unfortunately the .js functions have no concept of document.getElementById,
> is it possible to have external javascript files referencing page controls?
>
> Thanks
> Kev
>
>
>

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      09-02-2005
I don't understand the initial question, but I'm not sure Wajahat answered
it...

in a .js file, you can do document.getElementById("blah"); just fine...the
script is included in the page and works against that DOM

Perhaps what you are asking is how to get access to ASP.Net ClientIds ?
maybe you have stuff like
document.getElementById('<%=MyControl.ClientID%>') ; ??

in this case, no, your .js file doesn't have access to this. The one
solution is in your page create a bunch of js variables:

<script language=JavaScript">
//at bottom of page, or OnLoad event
var username = document.getElementById("<%=UserName.ClientId%>");
....
</script>

and then in your js file, you have access to the "username" javascript
variable...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"Wajahat Abbas" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Kev,
>
> Yes you can define a separate javascript validation file for your
> application. By default every .net web application, access the validaiton
> file resided in the asp_net_client directory of your wwwroot. But if you
> want
> to write your own js file , you can do that, once you define, all your
> validation methods call will forward to that file.
>
> What you have to do is to define a property in the web config file.
>
> <system.web>
> <webControls clientScriptsLocation="/script_files/"/>
> </system.web>
>
> And now place the WebUIValidation.js in the script_files folder,
>
>
> --
> Wajahat Abbas
>
> http://www.wajahatabbas.com
> http://www.dotnetpakistan.com
>
>
>
>
> "Mantorok" wrote:
>
>> Hi all
>>
>> I want to seperate my client-side validation into a seperate js file,
>> unfortunately the .js functions have no concept of
>> document.getElementById,
>> is it possible to have external javascript files referencing page
>> controls?
>>
>> Thanks
>> Kev
>>
>>
>>



 
Reply With Quote
 
bond_003 bond_003 is offline
Junior Member
Join Date: Jul 2009
Posts: 1
 
      09-07-2009
i tried creating javascript variables and keeping script in separate file. but i get 'list' not defined...thats the name of the variable i defined in the ascx page.
i implement the separate javascript file because i am using 2 instances of the same user control..and it seems that the javascript is working on that last user control that is added.

please let me know if there is a solution to having 2 instances of user control and working with javascript. i have used the 'clientid' to get unique id..but javascript is working with the last added user control
 
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
How to check what symbols are defined in a .o files? .a files? and.so files in linux? yinglcs@gmail.com C++ 3 01-18-2009 05:23 PM
somebody know why every time what published it changes the namedlls and aspx files has link to its files. Alejandro Pombo ASP .Net 0 01-25-2006 01:54 PM
how i can extract text from the PDF files,power point files,Ms word files? crazyprakash Java 4 10-30-2005 10:17 AM
Text files read multiple files into single file, and then recreate the multiple files googlinggoogler@hotmail.com Python 4 02-13-2005 05:44 PM
Help! Files, Files, and more Files ... Everywhere JeffS Digital Photography 22 09-19-2004 01:47 AM



Advertisments