Can not find control on Content page

2 posts, 1 answers
  1. Lubna Ansari
    Lubna Ansari avatar
    65 posts
    Member since:
    Feb 2010

    Posted 11 Mar 2010 Link to this post


    My program was working fine until I create a Master content page. I need to set values of some controls on a content page load using javascript and I am not able to find the controls on the content page. I am using a external .js file for the javascript funtion. Following is my Master Page code.

    <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="">
        <title>Untitled Page</title>
         <link rel="Stylesheet" type="text/css" href="StyleSheet/calendar-blue.css" />
        <link rel="Stylesheet" type="text/css" href="StyleSheet/template.css" />
        <script type="text/javascript" src="JS/JScript.js"></script>
        <asp:ContentPlaceHolder id="head" runat="server">
        <form id="form1" runat="server">
        <div id="divMasterPageContent">
       <!-- START Page Body -->
       <table id="tblCenterContent">
        <tr valign="top" height="100%">
         <!-- START Page Body - Left Panel -->
             <asp:ContentPlaceHolder id="cntContent" runat="server">        
         <!-- END Page Body - Right Panel -->
       <!-- END Page Body -->   

    Below is my Content page code.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="_Default1"
        MasterPageFile="~/MasterPage/MasterPage.master" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <asp:Content runat="server" ID="Default2" ContentPlaceHolderID="cntContent">
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" LoadingPanelID="LoadingPanel1">
                <div style="float: left; width: 500px">
        <asp:TextBox ID="txtTest" runat="server" Text="abc"></asp:TextBox>

    My Js code is












    It is returning me null value.



  2. Answer
    T. Tsonev
    T. Tsonev avatar
    2791 posts

    Posted 15 Mar 2010 Link to this post

    Hi Lubna,

    The server script block (<%=TransID.ClientID%>) will only work as part of the aspx page. In order to use an external file you need to pass the id as a parameter and resolve it on the page:

    In aspx:


    In js:


    I hope this helps.

    Kind regards,
    Tsvetomir Tsonev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top