473,396 Members | 1,722 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,396 software developers and data experts.

Page.ClientScript.RegisterClientScriptBlock renders incorrectly

The following code (VS 2008) does cause the script string to render, but it
doesn't render inside of <scripttags, instead the result is rendered just
after the opening <formtag, but outside of the other <scripttags that
are rendered automatically to handle my validation controls.

protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"function vailidateCardType(sender, args){");
sb.Append(@"if(form1.elements['lstCardType'].selectedIndex == 0)");
sb.Append(@"{args.IsValid = false;}");
sb.Append(@"else {args.IsValid = true;}");
Page.ClientScript.RegisterClientScriptBlock(this.G etType(),"customValidator",
sb.ToString());
}

Any ideas?
Sep 9 '08 #1
2 4658
Nevermind, I wasn't entering the 4th optional argument of true to indicate
that I wanted the <scripttags to render.

But, how could this method work without rendering the <scripttags?

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
The following code (VS 2008) does cause the script string to render, but
it doesn't render inside of <scripttags, instead the result is rendered
just after the opening <formtag, but outside of the other <scripttags
that are rendered automatically to handle my validation controls.

protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"function vailidateCardType(sender, args){");
sb.Append(@"if(form1.elements['lstCardType'].selectedIndex == 0)");
sb.Append(@"{args.IsValid = false;}");
sb.Append(@"else {args.IsValid = true;}");
Page.ClientScript.RegisterClientScriptBlock(this.G etType(),"customValidator",
sb.ToString());
}

Any ideas?

Sep 9 '08 #2
you supply the tags yourself. the only option for people writing in a script
other than javascript.if yo use the script flag, all the registered block go
into one script tag.

-- bruce (sqlwork.com)
"Scott M." wrote:
Nevermind, I wasn't entering the 4th optional argument of true to indicate
that I wanted the <scripttags to render.

But, how could this method work without rendering the <scripttags?

"Scott M." <s-***@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
The following code (VS 2008) does cause the script string to render, but
it doesn't render inside of <scripttags, instead the result is rendered
just after the opening <formtag, but outside of the other <scripttags
that are rendered automatically to handle my validation controls.

protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(@"function vailidateCardType(sender, args){");
sb.Append(@"if(form1.elements['lstCardType'].selectedIndex == 0)");
sb.Append(@"{args.IsValid = false;}");
sb.Append(@"else {args.IsValid = true;}");
Page.ClientScript.RegisterClientScriptBlock(this.G etType(),"customValidator",
sb.ToString());
}

Any ideas?


Sep 9 '08 #3

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

Similar topics

2
by: Arjen | last post by:
Hello, I want that the client script is added at the and of the HTML output it is now at the beginning. Here is my code: private void Page_Load(object sender, System.EventArgs e) {...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
0
by: Roy | last post by:
The following code - straight out of the MSDN help - uses ASP.NET 2.0's Client Callback features, and yet, ALWAYS postback to the page. Why? I expected no postbacks to occur. <%@ Page...
4
by: Nathan Sokalski | last post by:
I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script (2 Strings), but in ASP.NET the...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
3
by: Stan SR | last post by:
Hi, I need to place some javascript code at the end of my aspx page. How can I do that using the ClientScript.RegisterClientScriptBlock ? Thanks Stan
7
by: J055 | last post by:
Hi I have a list on LinkButton controls on a page. When the link is clicked the LinkButton.Command event does a Server.Transfer to a page which writes binary to the HTTP output stream, e.g. a...
8
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...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
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...
0
agi2029
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,...

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.