Click here to Skip to main content
16,011,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Im using visual studio 2005.
I want to use external javascript.

MY code is working proper widout master page.
But if i use master page than it's nt working.

Can anyone help me?


DEFAULT.ASPX
<%@ Page Language="VB" MasterPageFile="~/Master page/MasterPage.master" AutoEventWireup="false" CodeFile="A.aspx.vb" Inherits="A" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    
    <script type="text/javascript" src="JScript.js" language="javascript"></script>
    <form id="form1" runat="server">
    <div>
         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="return checkUser();"/><br />
       </div>
    </form>
</asp:Content>

=============================================
jSCRIPT.JS
JavaScript
function checkUser()
{
    if(form1.TextBox1.value=="xyz")
    {
        alert("Please enter appropriate value..");
        return false;
    }
    return true;
}
Posted
Updated 4-Feb-10 2:29am
v4

I think that the line that links to the external JavaScript should be moved to the HEAD section of the masterpage. That's this line;
ASP.NET
<script type="text/javascript" src="JScript.js" language="javascript"></script>
 
Share this answer
 
It call function if der is only alert message in function but when i add the if(form1.TextBox1.value=="xyz") click event not calling d function. I can't understand what is d reason behind it.
 
Share this answer
 
"It call function if der is only alert message in function but when i add the if(form1.TextBox1.value=="xyz") click event not calling d function. I can't understand what is d reason behind it."

der is only a word in German. d is a letter not a word. Don't talk like a retard, you have a full keyboard in front of you.

If your control even called TextBox1 on the client ? You need to use the ClientID property, not the name you give on the server.


manishathakkar wrote:
widout


You have no idea how ignorant this makes you look. This is a professional site, not a hangout for 12 year old boys.
 
Share this answer
 
Try
JavaScript
if(document.getElementById('TextBox1').value = "xyz")
{
....
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900