I've written a .js file and put the script in my usercontrol:
<script src="myscript.j s" />
Added the attributes to my controls:
lbl.Attributes. Add("onclick", "DoWork(this);" )
- Also tried "javascript:DoW ork(this);"
- and "javascript:DoW ork();" - to see if it was the "this"
I've also tried the RegisterClientS criptInclue() method to register
this script as well to no avail.
Where am I going wrong with this? 7 2035
"cfps.Christian " <ge*******@otc. eduwrote in message
news:95******** *************** ***********@s19 g2000prg.google groups.com...
I've written a .js file and put the script in my usercontrol:
<script src="myscript.j s" />
Added the attributes to my controls:
lbl.Attributes. Add("onclick", "DoWork(this);" )
- Also tried "javascript:DoW ork(this);"
- and "javascript:DoW ork();" - to see if it was the "this"
I've also tried the RegisterClientS criptInclue() method to register
this script as well to no avail.
Where am I going wrong with this?
Firstly, I'm assuming lbl is an <asp:Labelwebco ntrol... If so, it will
render as an HTML <span>. Does it actually contain any text...?
Secondly, do this as a test:
<asp:Label ID="MyTestLabel " runat="server" Text="Click me" />
MyTestLabel.Att ributes.Add("on click", "alert('Hello') ;");
When you click the word "Hello", do you see the JavaScript alert...?
If you do, then change the onclick attribute to "DoWork(thi s);" and put the
alert at the top of the DoWork method. Do you see the alert now...?
--
Mark Rae
ASP.NET MVP http://www.markrae.net
On Dec 11, 10:33 am, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
"cfps.Christian " <ge0193...@otc. eduwrote in message
news:95******** *************** ***********@s19 g2000prg.google groups.com...
I've written a .js file and put the script in my usercontrol:
<script src="myscript.j s" />
Added the attributes to my controls:
lbl.Attributes. Add("onclick", "DoWork(this);" )
- Also tried "javascript:DoW ork(this);"
- and "javascript:DoW ork();" - to see if it was the "this"
I've also tried the RegisterClientS criptInclue() method to register
this script as well to no avail.
Where am I going wrong with this?
Firstly, I'm assuming lbl is an <asp:Labelwebco ntrol... If so, it will
render as an HTML <span>. Does it actually contain any text...?
Secondly, do this as a test:
<asp:Label ID="MyTestLabel " runat="server" Text="Click me" />
MyTestLabel.Att ributes.Add("on click", "alert('Hello') ;");
When you click the word "Hello", do you see the JavaScript alert...?
If you do, then change the onclick attribute to "DoWork(thi s);" and put the
alert at the top of the DoWork method. Do you see the alert now...?
--
Mark Rae
ASP.NET MVPhttp://www.markrae.net
I've narrowed it down to it not finding the method. The alert in the
click event works, at the top of the method does not.
Also this is dynamic because I need to create a possibly endless list
and add all the properties to it as I add them. I click each line and
it give me a new line for the javascript error (same error though).
you have one of three errors:
1) DoWork spelled wrong, javascript is case senstive
2) myscript.js has a script tag inside
3) myscript.js is not in the same folder as the page loading the control
turn on javascript debugging in the browser and vs.
-- bruce (sqlwork.com)
"cfps.Christian " wrote:
I've written a .js file and put the script in my usercontrol:
<script src="myscript.j s" />
Added the attributes to my controls:
lbl.Attributes. Add("onclick", "DoWork(this);" )
- Also tried "javascript:DoW ork(this);"
- and "javascript:DoW ork();" - to see if it was the "this"
I've also tried the RegisterClientS criptInclue() method to register
this script as well to no avail.
Where am I going wrong with this?
Syntax wise everything is correct, I copy the method names to ensure
that. Also I can get other files to work fine but this is the first
time with the UserControl/Dynamic script thing which is where I'm
getting problems.
The js file is in a different location since this is a user control in
a separate folder.
I tried changing the path to the file to: "~/Controls/myscript.js"
with the same issue
the js file path must be relative to the page folder, not the control.
"~" is not valid in a script tag, only in the url of a server side control,
because thats the only way it gets translated (its not supported by iis or
the browser).
-- bruce (sqlwork.com)
"cfps.Christian " wrote:
Syntax wise everything is correct, I copy the method names to ensure
that. Also I can get other files to work fine but this is the first
time with the UserControl/Dynamic script thing which is where I'm
getting problems.
The js file is in a different location since this is a user control in
a separate folder.
I tried changing the path to the file to: "~/Controls/myscript.js"
with the same issue
Well you were correct about the having to be in the directory of the
page. I ended up putting the script tag in the calling page rather
than the user control.
Is there no way to reference a js file in a user control and just put
the user control in a page?
make the js file a web resource instead of a file.
-- bruce (sqlwork.com)
"cfps.Christian " wrote:
Well you were correct about the having to be in the directory of the
page. I ended up putting the script tag in the calling page rather
than the user control.
Is there no way to reference a js file in a user control and just put
the user control in a page?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel |
last post by:
Hello =)
I have an object which contains a method that should execute every x ms. I
can use setInterval inside the object construct like this -
self.setInterval('ObjectName.methodName()', this.pinginterval);
- but is there no way to do this without using the literal ObjectName? If I
write 'this.methodName()' I get "Line 1 Char 1: Object doesn't support this
property or method." in IE, and nothing happens in Firebird.
|
by: tshad |
last post by:
I have a function:
function SalaryDisplay(me)
{
var salaryMinLabel = document.getElementById("SalaryMin");
salaryMinLabel.value = 200;
alert("after setting salaryMinLabel = " + salaryMinLabel.value);
}
I also have an asp.net object:
|
by: sneill |
last post by:
How is it possible to take the value of a variable (in this case,
MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name?
In the following example I want 'oIcon' object to have the properties:
mode1, mode2, and mode3.
This seems simple but I can't quite figure it out...
Any ideas anyone?
|
by: jimjim |
last post by:
Hello,
This is a simple question for you all, I guess .
int main(){
double *g= new double;
*g = 9;
delete g;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl;
*g = 111;
cout<< sizeof(g)<<" "<<sizeof(double)<<" "<<sizeof(*g)<<" "<<*g<<" "<<endl;
|
by: Kiyomi |
last post by:
Hello,
I am trying to replace my alert message box with a popup page.
In my page behind,
| |
by: Sam Kong |
last post by:
Hello!
I got recently intrigued with JavaScript's prototype-based
object-orientation.
However, I still don't understand the mechanism clearly.
What's the difference between the following two?
(1)
|
by: Greg |
last post by:
I'm guessing the problem I'm having has something to do with Master Pages or
DetailsView because the exact same code works fine on a page without a Master
Page and DetailsView controls.
The problem is, when the javascript fires on the txtDateRequiredOut TextBox
in IE, I get "Error on Page" in the status bar and the error says: "Object
Expected". Viewing the source of the page while running shows a link created
properly for the linked...
|
by: JLuv |
last post by:
I have a javascript function defined in my <headtag on my ASP.NET
page. In the code-behind i have the lines...
void pGrid_DeleteCommand(object source, DataGridCommandEventArgs e)
{
string fName, lName;
fName = e.Item.Cells.Text.Trim();
lName = e.Item.Cells.Text.Trim();
Response.Write("<script language=javascript>confirmDelete('" +
fName + "', '" + lName + "')</script>");
|
by: Ralph |
last post by:
Hi
I don't understand why it's not working:
function schedule(imTop){
this.tdImagesTop = imTop;
}
schedule.prototype.selectEl = function() {
alert(this.tdImagesTop);
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |