473,775 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RegisterClientS criptBlock - does not work

Hi,

private void Page_Load(objec t sender, System.EventArg s e)
{
System.Text.Str ingBuilder strBuilder = new System.Text.Str ingBuilder();
strBuilder.Appe nd ("<script language=JavaSc ript> ");
strBuilder.Appe nd ("<!--");
strBuilder.Appe nd ("var intWidth = window.screen.a vailWidth - 40;");
strBuilder.Appe nd ("var intHeight = window.screen.a vailHeight - 60;");
strBuilder.Appe nd ("var strHrf;");
//DoD function
strBuilder.Appe nd ("function DoDClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue = false;");
strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf = 'Ship/ShDoD.htm';}");
strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DoD.aspx';}");
strBuilder.Appe nd ("newWindow(Sit e, 'DoD', intHeight, intWidth, true,
false, true, false);}");
strBuilder.Appe nd ("function SiteClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue = false;");
strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf = 'Ship/ShDefaultShip.h tm';}");
strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DefaultShore.h tm';}");
strBuilder.Appe nd ("newWindow(str Hrf, 'RADWeb', intHeight, intWidth,
true, false, true, false);}");
strBuilder.Appe nd ("-->");
strBuilder.Appe nd ("</script>");
string js = strBuilder.ToSt ring();
if (!IsClientScrip tBlockRegistere d("DoDClick") )
{
RegisterClientS criptBlock("DoD Click", js);
}

if (!IsClientScrip tBlockRegistere d("SiteClick" ))
{
RegisterClientS criptBlock("Sit eClick", js);
}
}

------------------------------

Everything looks good. No error.
Also get
IsClientScriptB lockRegistered = true

No Javascript is genrated when I view source code.

Not sure what I am doing wrong.

Thanks,

- Reena
Nov 15 '05 #1
3 5562
-----Original Message-----
Hi,

private void Page_Load(objec t sender, System.EventArg s e)
{
System.Text.Str ingBuilder strBuilder = new System.Text.Str ingBuilder(); strBuilder.Appe nd ("<script language=JavaSc ript> ");
strBuilder.Appe nd ("<!--");
strBuilder.Appe nd ("var intWidth = window.screen.a vailWidth - 40;"); strBuilder.Appe nd ("var intHeight = window.screen.a vailHeight - 60;"); strBuilder.Appe nd ("var strHrf;");
//DoD function
strBuilder.Appe nd ("function DoDClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue = false;"); strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf = 'Ship/ShDoD.htm';}");
strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DoD.aspx';}");
strBuilder.Appe nd ("newWindow(Sit e, 'DoD', intHeight, intWidth, true,false, true, false);}");
strBuilder.Appe nd ("function SiteClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue = false;"); strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf = 'Ship/ShDefaultShip.h tm';}"); strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DefaultShore.h tm';}");
strBuilder.Appe nd ("newWindow(str Hrf, 'RADWeb', intHeight, intWidth,true, false, true, false);}");
strBuilder.Appe nd ("-->");
strBuilder.Appe nd ("</script>");
string js = strBuilder.ToSt ring();
if (!IsClientScrip tBlockRegistere d("DoDClick") )
{
RegisterClientS criptBlock("DoD Click", js); }

if (!IsClientScrip tBlockRegistere d("SiteClick" ))
{
RegisterClientS criptBlock("Sit eClick", js);
}
}

------------------------------

Everything looks good. No error.
Also get
IsClientScriptB lockRegistered = true

No Javascript is genrated when I view source code.

Not sure what I am doing wrong.

Thanks,

- Reena
.
Reena - I created a new project, cut & paster your code

and it ran without error. Did a 'View Source' and it was
there. Did you try a new project to see if maybe there's
something else wrong with your existing project?
Nov 15 '05 #2
Thanks Joel. Tried with new project. Works fine. Can see javascript in view
source.

Error while accessing javascript...

Microsoft JScript runtime error: Object expected

---------------- HTML Code ----------------
<a id="hrfShip" onclick="SiteCl ick('SHIP')" href="-">Ship:</a>
<a href="-" onclick="SiteCl ick('SHORE')">S hore:</a>
<a href="-" onclick="DoDCli ck('<% =Session["RADSite"] %>')">DoD
Disclamier</a>

_______________ ______

Thanks,

- Reena

"joel" <jo**@brandes.n ospam.com> wrote in message
news:42******** *************** *****@phx.gbl.. .
-----Original Message-----
Hi,

private void Page_Load(objec t sender, System.EventArg s e)
{
System.Text.Str ingBuilder strBuilder = new

System.Text.Str ingBuilder();
strBuilder.Appe nd ("<script language=JavaSc ript> ");
strBuilder.Appe nd ("<!--");
strBuilder.Appe nd ("var intWidth =

window.screen.a vailWidth - 40;");
strBuilder.Appe nd ("var intHeight =

window.screen.a vailHeight - 60;");
strBuilder.Appe nd ("var strHrf;");
//DoD function
strBuilder.Appe nd ("function DoDClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue =

false;");
strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf = 'Ship/ShDoD.htm';}");
strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DoD.aspx';}");
strBuilder.Appe nd ("newWindow(Sit e, 'DoD', intHeight,

intWidth, true,
false, true, false);}");
strBuilder.Appe nd ("function SiteClick(Site) {");
strBuilder.Appe nd ("window.event. returnValue =

false;");
strBuilder.Appe nd ("if (Site == 'SHIP'){");
strBuilder.Appe nd ("strHrf

= 'Ship/ShDefaultShip.h tm';}");
strBuilder.Appe nd ("else{");
strBuilder.Appe nd ("strHrf = 'DefaultShore.h tm';}");
strBuilder.Appe nd ("newWindow(str Hrf, 'RADWeb',

intHeight, intWidth,
true, false, true, false);}");
strBuilder.Appe nd ("-->");
strBuilder.Appe nd ("</script>");
string js = strBuilder.ToSt ring();
if (!IsClientScrip tBlockRegistere d("DoDClick") )
{
RegisterClientS criptBlock("DoD Click",

js);
}

if (!IsClientScrip tBlockRegistere d("SiteClick" ))
{
RegisterClientS criptBlock("Sit eClick", js);
}
}

------------------------------

Everything looks good. No error.
Also get
IsClientScriptB lockRegistered = true

No Javascript is genrated when I view source code.

Not sure what I am doing wrong.

Thanks,

- Reena
.
Reena - I created a new project, cut & paster your code

and it ran without error. Did a 'View Source' and it was
there. Did you try a new project to see if maybe there's
something else wrong with your existing project?

Nov 15 '05 #3

"Reena" <pa*****@navsea .navy.mil> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
Hi,

private void Page_Load(objec t sender, System.EventArg s e)
{
System.Text.Str ingBuilder strBuilder = new System.Text.Str ingBuilder();
strBuilder.Appe nd ("<script language=JavaSc ript> ");
strBuilder.Appe nd ("<!--");
strBuilder.Appe nd ("var intWidth = window.screen.a vailWidth - 40;");
strBuilder.Appe nd ("var intHeight = window.screen.a vailHeight - 60;");
strBuilder.Appe nd ("var strHrf;");

<etc.>

Reena,

just a tip:

you could write this as
string js = @"<script language=JavaSc ript>
<!--
var intWidth = window.screen.a vailWidth - 40;
var intHeight = window.screen.a vailHeight - 60;
var strHrf;
<etc>";

this is, as a single multi-line string. For a fixed text it is easier to
read.

Hans Kesting


Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2487
by: MS News | last post by:
Hello, Where can I find RegisterClientScriptBlock() Page class does not have it. Do I have to Import or add some special reference?? what about RegisterScript which I can see but can not do anything with it
1
2929
by: Mark | last post by:
I've been reading the following link : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html /aspnet-injectclientsidesc.asp That supposedly tells you how to use these: RegisterStartupScript() and RegisterClientScriptBlock() to inject client side script into a server control. I'm new to ASP.NET and am hoping someone can help. I'm trying to get this snippet: <script language="JavaScript1.2"...
2
1992
by: Earl Teigrob | last post by:
I have a Web Custom Control that builds javascript to write to the page. The DatePickerJs() function builds over 500 lines of javacript code. Even thought my Custom Web Control does not write it to the client, it regenerates the string very time this control appears on a page. Is there a way to create this string ONCE and then just use if every time after that? CODE
2
3095
by: sam | last post by:
I am trying to emit script to the response stream within the Application_Error handler in global.asax. I want to emit using Page.RegisterClientScriptBlock. This doesn't work, and I have been reading that you can not get access to the Page class from within global.asax. But I am able to get a hold of the response object through context.current and submit using response.write, though I want more control. If it is possible to do a...
0
1131
by: pealy2 | last post by:
A quick pointer to anyone struggling with the RegisterClientScriptBlock function, unless you already have a <FORM> section in your page then the script will not be added. I use vb code to generate all my visual objects on a page and it took me ages to work out why it wouldn't work on that page. The simple solution is to manually add a <FORM> </FORM> section to your page (I found a page which did have the section to see where to put it) ...
2
2822
by: kewl | last post by:
Hi All, We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far: // Go thru each datarow in the datatable foreach (System.Data.DataRow drReportGroupsDetails in tableReportGroupsDetails.Rows) { // Get the needed values from the datatable string reportName = (string)drReportGroupsDetails; string reportPath = (string)drReportGroupsDetails;
9
1393
by: Nathan Sokalski | last post by:
I have used the RegisterClientScriptBlock method in external functions of mine (ones that are saved in a separate *.vb file), where I use them as follows: Public Shared Sub MyFunction(ByVal txtbox As TextBox) 'other code txtbox.Page.RegisterClientScriptBlock("mykey","myscript") 'other code End Sub
3
6637
by: | last post by:
Hello, I try to open a new Window in code behind with : ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript", "window.open('toto.doc');", true); My problem is that the new window is created but it disappears immediatly just after creation!! For information, I tried this:
8
6635
by: =?Utf-8?B?UGF1bCBSZWVk?= | last post by:
Hello, I have an app that was xcopy deployed from an ASP.NET 1.1 W2KServer to a box running ASP.NET 2.0 W2003Server. The app runs fine with the exception of where I use the above method. It just doesn't seem to work at all anymore. I get no errors...but what used to work...now just doesn't work. I use it to emit jscript from an opened window to reflect changes being made back on the parent window that launched it. Any ideas?
0
9454
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,...
0
10268
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, 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...
0
10107
jinu1996
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...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7464
isladogs
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...
0
6718
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();...
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.