0

Hi, I got one masterpage and one content / child page having gridview control

I want to do client side validations using javascript, can anyone suggest me where i have to do this.
i.e.., either in masterpage or in content page
(I know that only at the <head> tags we can include javascript file, but in content pages there are no html tags, please suggest),

i don't want to use server side validation controls , and i want to validate the server side controls in gridview

3
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by amitshrivas
0

You can place a content placeholder in the header area of your master page. That way child pages can choose to utilize that placeholder for items such as scripts, extra stylesheet references, etc., that may not be applicable to all pages.

0

You can place a content placeholder in the header area of your master page. That way child pages can choose to utilize that placeholder for items such as scripts, extra stylesheet references, etc., that may not be applicable to all pages.

But when i placed another content place holder in <head> tag, it is showing that <asp:contentplaceholder> is invalid tag, and also i can't see that contentplaceholder in content/child pages.

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

<!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="contentHeader" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="contentBody" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

This works. In fact, if you're working in Visual Studio 2008 / Web Developer Express 2008, you'll get this by default when you create a master page. It still works in VS 2005, though. Check that you've got IDs and runat=server in all the appropriate places.

Edited by apegram: n/a

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

<!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="contentHeader" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="contentBody" runat="server">
        
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

This works. In fact, if you're working in Visual Studio 2008 / Web Developer Express 2008, you'll get this by default when you create a master page. It still works in VS 2005, though. Check that you've got IDs and runat=server in all the appropriate places.

Sorry for the late reply! I am out of station for last 5 days,

Hey when i am doing that thing i came across another blank content place holder in the website (webpage)

But if we want to validate more than 1 content pages, what i've to do, i have to keep on adding the content place holder or i can use the previouse one(which will create confusion).

and also now i am using Javascript, but i came to know that
we can also write the client side validations using asp server side validation controls.

Can u give me a simple example w.r.t the above sentence.

Thanks in advance.

Edited by kiranbvsn: n/a

0

The master page has the content placeholder in the header. Child pages can choose to use that content place holder or skip it. If you have a form on child page #1 that you want to do custom client-side validation on, you place your javascript (or javascript source reference) within an asp:Content block tied to that placeholder. No other child page is bound by that javascript because it is only on child #1. Child #398 can have an entirely different validation requirement and therefore use a different script.

Edited by apegram: n/a

0

Hi, I got one masterpage and one content / child page having gridview control

I want to do client side validations using javascript, can anyone suggest me where i have to do this.
i.e.., either in masterpage or in content page
(I know that only at the <head> tags we can include javascript file, but in content pages there are no html tags, please suggest),

i don't want to use server side validation controls , and i want to validate the server side controls in gridview

...........................
This code will help u as i also suffer this problem and found the solution..

In ur MasterPage.aspx.cs/vb write This Code.

protected void Page_Init(object sender, EventArgs e)
    {
        this.ID = "MyMasterPage"; // or whatever name you prefer
    }

then after
inside your contentplaceholder use javascript as u need..

and how to access the values of controlss..

document.getElementById('MyMasterPage_ContentPlaceHolder1_urcontrolid/name').value;

i hope this will help u surely..

Edited by amitshrivas: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.