Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page.ClientScript.RegisterClientScriptBlock renders incorrectly

Reply
Thread Tools

Page.ClientScript.RegisterClientScriptBlock renders incorrectly

 
 
Scott M.
Guest
Posts: n/a
 
      09-09-2008
The following code (VS 200 does cause the script string to render, but it
doesn't render inside of <script> tags, instead the result is rendered just
after the opening <form> tag, but outside of the other <script> tags 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?


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      09-09-2008
Nevermind, I wasn't entering the 4th optional argument of true to indicate
that I wanted the <script> tags to render.

But, how could this method work without rendering the <script> tags?

"Scott M." <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> The following code (VS 200 does cause the script string to render, but
> it doesn't render inside of <script> tags, instead the result is rendered
> just after the opening <form> tag, but outside of the other <script> tags
> 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?
>



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-09-2008
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 <script> tags to render.
>
> But, how could this method work without rendering the <script> tags?
>
> "Scott M." <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > The following code (VS 200 does cause the script string to render, but
> > it doesn't render inside of <script> tags, instead the result is rendered
> > just after the opening <form> tag, but outside of the other <script> tags
> > 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?
> >

>
>
>

 
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
controls in grid layout render incorrectly in firefox =?Utf-8?B?RGF2ZQ==?= ASP .Net 3 12-15-2005 04:00 PM
SelectedIndex Value Reported Incorrectly Nathan Sokalski ASP .Net 6 10-06-2005 06:17 PM
Non-noise words are incorrectly recognised as noise words. Peter Strĝiman ASP .Net 1 08-23-2005 01:26 PM
Session variables and cookies are incorrectly accessible between applications Galina Grechka ASP .Net 3 01-19-2005 06:24 PM
Treeview renders incorrectly in IE Alfred Salton ASP .Net Web Controls 1 08-19-2003 04:32 PM



Advertisments