473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Register Client Scripts wont add javascript to page (C# Web App)

32
Hi,

In my page load event i have:-

RegisterClientScripts();
if (!Page.IsClientScriptBlockRegistered("BannerScript "))
if (!IsPostBack)
{
_userLink.Attributes.Add("onclick", string.Format("ShowPopupWindow('UserWindow');"));
}

My RegisterClientScripts consists of:-

private void RegisterClientScripts()
{
string jscriptFunctions = @"<script type='text/javascript'>
<!--
function ShowPopupWindow( windowName )
{
top.OpenWindowByName( windowName );
}
//-->
</script>";

// Register the script block

ClientScript.RegisterClientScriptBlock(this.GetTyp e(), "BannerScript", jscriptFunctions);
}

I have a ASP Hyperlink in the html:-


<asp:HyperLink ID="_userLink" runat="server" NavigateUrl="#" ImageUrl="~/images/User.gif" ToolTip="User Management" >User</asp:HyperLink>

When I run my program I get a javascript error - Object expected. When I view source the Javascript code doesn't appear.

I know this will be something really simple - but I just cant see it - you know how it is.

Any ideas will be appreciated

Thanks
Janet
Jun 5 '07 #1
3 7867
kenobewan
4,871 Expert 4TB
Do you declare windowName anywhere? Does the error message give you a line number?
Jun 5 '07 #2
dixonjm
32
I have found the problem - I hadn't wrapped the table in the hml into a form - this has definately sovled the problem.

Many thanks anyway - Thats the first time I have posted a request in a forum & I dont suppose I explained it very clearly.
Jun 5 '07 #3
Motoma
3,237 Expert 2GB
I have found the problem - I hadn't wrapped the table in the hml into a form - this has definately sovled the problem.

Many thanks anyway - Thats the first time I have posted a request in a forum & I dont suppose I explained it very clearly.
Glad you have found your answer, thank you for posting the solution for others to see!
Jun 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not...
6
by: jake | last post by:
How do you get or save a file from/to a client (button on web page) once they are authenticated? The client could be Mac, Linux or Windows. Can I do it all with IIS and ASP.NET?
3
by: Hardy Wang | last post by:
Hi, By calling Page.RegisterClientScriptBlock, the JavaScript will be generated right after VIEWSTATE hidden field. Is there a way I can register my script to end of page instead beginning? --...
2
by: Stu | last post by:
Hi, I am migrating a large app to .Net 2 and am having problems with accessing hidden fields using javascript. As I am using masterpages the control names are prefixed with the control...
3
by: ABC | last post by:
How to debug client-side script (javascript) from VS2003 or VS2005?
6
by: Mike Chen | last post by:
We know in server code, we can check the page validated by using Page.IsValid where we put some validator controls on aspx page. I want to set some value after validating user input values on...
1
by: doubtraiser | last post by:
Hai friends, Is it possible to get the IP address of the client machines using javascript .The server i set up using Tomcat 5. The requirement is to get the ip...
2
by: krev | last post by:
Is is possible to check the version of a software installed in client system using javascript?
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.