<script language="javascript" runat="server"> can't be used?

I place this inside on a content page:
 

<script language="javascript" runat="server">
function ontextchange()
{

 document.getElementById("ctl00_ContentPlaceHolder1_lbl_CatchInfo").innerHTML = "change in text or whatever";

}
</script>
 and get an error saying JavaScript can't be used as another language has been stated by the CodeFile-attribute...? It works if i remove the runat=server tag----What is wrong???
0
mm8
9/9/2008 8:18:21 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1138 Views

Similar Articles

[PageSpeed] 5

javascript is a client side language. take out the "runat =server" part and see what happens

0
richiej
9/9/2008 8:59:18 AM

Because you have already defined Language = "C#" or VB.NET in Page attribute

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Page2.aspx.cs" Inherits="WebApplication2.Page2" %>

So again if you say Script language = Javascript this will give exception, to get this thing working just remove the Language="C#"  from Page attributes

 


Please remember to click “Mark as Answer” on the post that helps you

Best Regards
Brij Mohan
http://www.dotnetglobe.com
0
mohanbrij
9/9/2008 9:02:22 AM
Reply:

Similar Artilces:

2 script tags, Script Language="javascript" and Script runat="server" in a web form.
Where should i place the javascript portion in the webform if i already had my <script runat="server"> (VB) place afterthat? Mark up: i understand that it should have 2 script tags used in the web form.  <SCRIPT LANGUAGE="JavaScript"> var isNN = (navigator.appName.indexOf("Netscape")!=-1); ...etc</script> <script runat="server">     Dim x, iRow, iCol, noRec As Integer   Dim i As Integer ... etc. <script> <asp:Content ID="First" ContentPlaceHolderID="aad"...

can I delete <form id="form1" runat="server"> and </form>
Hi: Our website is written by using simple html code, one of the page has some virtual shopping cart code with <form> ....</form>, (for example here: http://www.centercoin.com/coin_supplies/coin_collecting_starter_set.htm ), if I have 10 products, I will have 10 of <from> ...</form> in this page, that is ok. Now, I am trying to redesign the website using asp.net2.0, I notice all the asp page will automatically create a <form id="form1" runat="server"> ...</form>, such as: <html xmlns="http://www.w3.org/19...

When I use Response.Write("<script type='text/javascript' language='javascript'>window.close();</script>"); it produces error
Hi, When I use command below in my web application  it produces error. How can I solve this problem? Thanks.Response.Write("<script type='text/javascript' language='javascript'>window.close();</script>");   Error:  Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.Details: Error parsing near &#...

Can I pass a parameter in here: Response.Write("<script language='Javascript'>window.open('ReportUmpireGrading.aspx')</script>")
HelloI am using this line of code to start a page for my report but I now need to pass  string parameters to that new page being popped-up. Response.Write("<script language='Javascript'>window.open('ReportUmpireGrading.aspx')</script>")Can I do it?ThanksI think, therefore I am Is this what you are after??? Response.Write("<script language='Javascript'>window.open('ReportUmpireGrading.aspx?q" & asdf & "&e=" & sdfg &"')</script>")EricPascarello.com | Twitter epascarello | LinkedIn Response.Write is evil. What A1ien51 has written is correct...

Code Behind or "<script runat="server">...code...</script>"?
Hi, I've just started learning asp.net after a number of years with VB. A lot of the examples I've been researching have placed the VB code directly onto the .aspx web page with a "<script runat="server">...code...</script>" format rather than placing the code in a "code behind" .vb page. Is there any reason for this other than the fact that you can place all the relevant code onto one example? From a .Net Studio point of view, it's seems to be far easier to use Code Behind, as one can take advantage of the "Auto Complete" features th...

What if I remove <form id="form1" runat="server"></form>
If I am creating an aspx page, which does not need to be a form, i.e. no input is taken from the user, do I need to encapsulate the whole page with in  <form1 runat="server">   What are the implications of removing the form? I realize there will be no viewstate, and again, I won't be able to accept user input, but will everything else work as expected? It seems to be so far, I've just not seen ANY examples where the form tag has been removed. Thanks, Darragh You need the server-side form tag if you are going to have server-side controls on the form.RyanRyan Olshan...

using "<input type="file" runat="server">"
im do somthing like that : <input id="test1" type="file" runat="server"> i want that after the form posted the value in the "test1" and not clear (like it right now) how can i do this??... Thanks"Live you life best way you can " you can get all information from: test1.PostedFile Best Regards, Vivek Singh i mean that if i post the form to the same page i don't want the value in the <input type=file> (test1) will clear "Live you life best way you can " You mean you'd want the upload field t...

<form id="form" runat="server">
hey i have a very similar problem to this thread http://forums.asp.net/thread/1440587.aspx"Control 'ctl00_ContentPlaceHolder1_Login1' of type 'Login' must be placed inside a form tag with runat=server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Control 'ctl00_ContentPlaceHolder1_Login1' of type 'Login' must be placed inside a form tag with r...

Can't use "defaultbutton" in <form></form> tag in login control page.
I have a login control and I tried to set the default button as the submit button within my form tag in the login page.But, I am getting the following error.Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. I already generated the machine key.Any clue! hi robin, Please try this fix if.. add the below given code into your web.config or the file that you are executing and see if your issue gets...

How to put Response.Write("<script language='javascript' type='text/javascript'>") into custom server control
Hello, In my Page_Load I have the following code: =====  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Response.Write("<script language='javascript' type='text/javascript'>" & vbCrLf) Response.Write("Function();") Response.Write("</script>") End Sub =====  Because I want to re-use this on every webpage, I want to build a custom server control. How can I implement this?Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". ...

<script language='JavaScript'>location.href="#control"</script>
I tried to use asp to register this block of script into the page to direct the page to the control that the user was working on before postback, it works fine on IE, however, when I try it on netscape, the page is not showing but when I do view source, all the code are there. Anybody knows what happened and how to fix it? Thanks in advance. My guess would be that Netscape just happens to be pickier about the url starting with a hash. Try using the entire url plus the hash and see if Netscape behaves better. > Try using the entire url plus the hash Hmmm ... that might actua...

what's the different from "<page src="">" and "<page codeBehind="">"
what's the different from "<page src="">" and "<page codeBehind="">" Thank YOU how to make session' life longer? Thank You This very question was asked only 5 days ago. Searching the forums would have yielded the answer you require. However, see this thread. Steven BeyRecursion: see Recursion You can set a new value for the Session Timeout in your web.config file. Or, you can do it in a page through this property: Session.Timeout Note that if you choose the second method, the timeout will only be modified on this page,...

<form id="form3" runat="server">
i am really confused about the <form id="form3" runat="server">  error i receive the thing is LoginStatus1 andCreateUserWizard1both require their components to run at the server. however only one form server is allowed in the document. i receive this error message in the browser, and vice versa for the other component.Server Error in '/vwd test/Techworld' Application. A page can have only one server-side Form tag. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for mor...

Can't get away from: "Could not open in Design View. Quote values differently inside a '<% ... "value" ... %>' block."
I keep getting this error message when I try to switch to design view. This is the code that is causing it. OnClick="javascript:void(0);ToggleRowDisplay(this,'row<%# DataBinder.Eval(Container.DataItem, "Equipment_ID") %>');" When I take out this section I can go into design view without a problem. Any ideas?? is the word row has to be there?mess with the best...die like the rest...

Web resources about - <script language="javascript" runat="server"> can't be used? - asp.net.web-forms

Resources last updated: 12/16/2015 2:06:35 PM