Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Master.master.cs" Inherits="Master" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<asp:ContentPlaceHolder id="head" runat="server">
<%--Place for title--%>

<link rel="stylesheet" href="css/layout.css" type="text/css" media="all"/>
<link rel="stylesheet" href="css/style.css" type="text/css" media="all"/>
<script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/script.js"></script>
<link href="css/loginPopup.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">


……
……

This is my Content Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<title>Register with Us</title>
<link href="css/template.css" rel="stylesheet" type="text/css" />
<link href="css/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#form1").validationEngine();
});
</script>

<asp:Content ID="Content3" ContentPlaceHolderID="main_body" Runat="Server">


…….
…….

Dear Sir, As you can see in my above Content Page , there is a jQuery function using form id(form1). the problem is that form/form ID is in master page. That'swhy this jQuery function is not working. Pls help me by telling solution.
Posted

Try using $("#<%= form1.ClientID %>") this can work for you....
 
Share this answer
 
You can write the

JavaScript
$(document).ready(function($){}); 


function in the master page or if you want to do it only in some specific page
then you can write it in different .js page and include it in that specific page only.

Thanks
Ipsita
 
Share this answer
 
If you want to use jQuery to be invoked on any server side element, you need to retrieve the ClientID of that. ClientID is the client referential id which is used in the id selector '#'

So for this case, use
JavaScript
$('#' + '<%form1.ClientID%>')
. This will need to be done when the control is in a place where its Id can be dynamically generated, like within a parent control (grid etc).
 
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