Click here to Skip to main content
15,913,055 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I'm using visual studio 2010 and I want to start Jquery from scratch but I'm not having the proper output as supposed.
I've made new asp empty website and added masterpage in it the code for masterpage goes:

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

<!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">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1"  runat="server">
      <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
    <Scripts>
      <asp:ScriptReference Path="Scripts/jquery-1.4.1.min.js" />
    </Scripts>

    <div>
      <div class="red">
        <p>HELLO WORLD</p>
      </div> 
      <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
    </div>
    </form>
</body>
</html>


and added another empty web form selecting the existing masterpage
code of emptyweb form
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="jQ.aspx.cs" Inherits="jQ" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
<script type="text/javascript">
$(document).ready(function() {
$('.red').addClass('color');
});
</script>


and added the css,code of css is

CSS
.color
{
  font-style: italic;
  text-decoration: underline;
}


I don't know what is wrong,I'm supposed to be getting HELLO WORLD in italics and underlined but its plain.
Gracias for helping :D
Posted
Updated 25-Feb-11 21:16pm
v5

you are forgeting to close your asp:ScriptManger tag

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
<Scripts>
<asp:ScriptReference Path="Scripts/jquery-1.4.1.min.js" />
</Scripts>
</asp:ScriptManager>
 
Share this answer
 
v2
Comments
prathoven 26-Feb-11 10:58am    
Thanx for the zillion brother..I had stucked for many days trying to figure it out and can't believe I missed the tag.Thank you once again.:)
I just tried your code on a simple HTML page (without master page) and it worked as expected.

I think the first thing that you need to check is -
Is your element getting selected or not and is JavaScript executing against it?
Use a script debugger to do so.
 
Share this answer
 
Comments
prathoven 26-Feb-11 6:31am    
thanx for the reply and I think I pretty sure that I use the right selector
Ankur\m/ 26-Feb-11 6:58am    
I never said you are using a wrong selector. It worked for me. I basically wanted you to check if the element is getting selected AND JavaScript is executing against IT.
Could you check the rendered html page if the reference to jquery.js is added or not?
if not once I had the same problem, I used to map the js file like this:
C++
<script language="javascript" type="text/javascript" src='<%# Page.ResolveUrl("~/JavaScript/jquery.js") %>'></script>


Please check if it works for you.

Thanks
 
Share this answer
 
Comments
prathoven 26-Feb-11 6:32am    
Thanx for the reply Ahmad. I tried it but it didn't work.
Try the following, hope it will work :
XML
<head runat="server">
    <title></title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder id="head" runat="server">
</head>



I hope the above information will be helpful. If you have more concerns, please let me know.


If this would be really helpful to you then don't forgot to Vote and Make Answer as Accepted.
 
Share this answer
 
v4
Comments
prathoven 26-Feb-11 6:33am    
Thanx for the reply Monjurul..I guess that's the same code as mine :)
Monjurul Habib 26-Feb-11 6:47am    
did you try? place your css above the PlaceHolder.
prathoven 26-Feb-11 6:50am    
yes, I did....
Monjurul Habib 26-Feb-11 7:24am    
did you place your css above the PlaceHolder? and still its not working ??
prathoven 26-Feb-11 9:39am    
Yes..I did and I'm still putting css code above placeholder.

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