.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Content page control passes as argument to javascript function

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

View Complete Post

More Related Resource Links

Accordion control access in Javascript using Content page

Hi, I struggled with some javascript issues, and discovered that the problem seemes to come from a failed ajax control access.Here's my problem:I have a master page and a content page.In my content page, I have an accordion with 2 panes.1rst pane: a textbox and a validation button;                     I want the button to fire javascript function without reloading page (using "return false;");In my master page, I put my ToolkitScriptManager.In my content page, I put my script containing the functions.The problem is that it seems like I can't access the accordion control in my js functions, whereas I can access my textbox value...Here is my source:<%@ Page Language="C#" MasterPageFile="~/Default.master" Title="CLEOR RH | Home" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script type="text/javascript"> var step1 = false; function pageLoad() { var accCtrl = $find('AccordionCtrl_AccordionExtender');

Call javascript function on containing page from user control


I have a toolbar in a user control.  I would like to wire the toolbar's onclick event to a javascript function on the page that contains the user control.  What's the easiest way to do this?

Getting Selected Item in radiobuttonlist on content page using javascript

I am trying get the selected value from a radiobuttonlist on a content page using javascript. Here is my initial code, which does not recognize the control. The js is located in a separate file and there is a link on the content page pointing to the js file. Thanks, function GetRadioButtonValue() { var radio = document.getElementsByName('<%=rblPayType.ClientID%>'); for (var j = 0; j < radio.length; j++) { if (radio[4].checked) { alert(); return; } else { return; } } }    

Access UserControl Control from a JavaScript Function

I have a requirement to launch a Modal Javascript dialog box from within my usercontrol,I have done this by <code> function browseControlAction(ProjID,ControlID) { strPrompt = 'Select a Previous control action..'; strOptions = 'dialogWidth:25;dialogHeight:30;status:no;resizable:yes'; selectedAction = window.showModalDialog('browseControlActions.aspx?ProjID=' + ProjID + '&Control=' + ControlID, strPrompt, strOptions); var sControl = ' + ControlID + '; if (selectedAction != null) { alert(ControlID.toString()); alert(selectedAction); var sTest = ControlID + '_txtControlAction'; alert(sTest); var sTest2 = 'txtSummary'; alert(sTest2); document.getElementById('txtCurrentControls').innerText=selectedAction;   //this works as this a control on the page itself document.getElementById(sTest2).innerText=selectedAction;      //Ditto document.getElementById(sTest).innerText=selectedAction;    //This Fails as this is the control in the USercontrol I am trying to Access //__doPostBack('',''); }</code>can anybody tell me why I can't access the Textbox control on the USercontrol?

Client Javascript runs, but then page errors out when clicking on a control that uses postback

Using this script on a button click <script language="javascript"> function printdiv(printpage) { var headstr = "<html><head><title></title></head><body>"; var footstr = "</body>"; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; document.body.innerHTML = headstr + newstr + footstr; window.print(); document.body.innerHTML = oldstr; return false; } </script> After it is done, I can't click on my calendar control.  I was hoping to add somethign that would force a refresh in the script, but nothing I do works. Any thoughts?  Thanks! 

execute a javascript function in code page

I use js function in source page and call that js function as below in Source page<a href="javascript:;" onclick="openwin('Sample.aspx?DID=<%#Eval("UID") %>', '', '700','300','yes'); return false ">I need to call this function from vb.net code page.....how to solve this ........???????????Give ur ideas...............

How to call javascript function in master page

helloi have javascript file 'script.js' where i have writt en a function for print. but this function is working fine if i am not using master page in my report page but the question is i want to use master page for my report page where i am calling javascript function but it is not working . Do help me regarding MasterPage and Javascript function.

find control in datalist by javascript(Not by Code Behind CS Page or ItemDatabound)


Hello all,

I am facing a problem with javascript.Following is the scenario:

I am working on survey application......

I have taken a datalist in which the question in survey are bound in a label control

now user can change color of the question using color picker

color picker have a popup which is closed when user selects a color and

the color of question will be updated as popup closes

So i have to find label control(in which i bound questions)

in datalist by javascript only (not by Cs page or by itemdatabound event because of color picker popup i can not use cs page)

and update the color of label selected by color picker

I googled and found following code but it show null value

var lbl = document.getElementById('<%= Page.Master.FindControl("ContentPlaceHolder1").FindControl("dList").FindControl("lblQuestion") %>');

when I saw the page source following id is generated for label

and so on


Getting Content Control on Content Page in Visual Studio


Visual Studio 2010

Working on a content page (.aspx page with associated master page)

Not all of the content place holders from the master page are represented on the content page (have been deleted)

Can go to the master page, find the place holder I want, return to content page and type out the "content" tag.

Is there an easier way? Can I drag a content tag in from a toolbox somewhere? Can I "re-apply" a master page to a content page and have it restore missing place holders? Looking for the lazy way out.

How to pass argument to javascript function



in aspx page i have taken a simple html anchor tag like this:

<a id="l1" href="javascript:OnLookup();">Click</a>

when "Click" is clicked, that OnLookup function is called. But if i want to pass argument in that function then how can i pass ?

This anchor tag is generated dynamically through another javascript function.There can be more than one anchor tags, and each having different arguments in OnLookup function call .

How can pass arguments dynamically ?

How to trigger a JavaScript function using "onmouseover" event on a SPMenuField control?



I could do something along these lines for TemplateField (with ItemTemplate having a HyperLink control):

private void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
     if (e.Row.RowType == DataControlRowType.DataRow)    
          ((HyperLink)e.Row.FindControl("lnk_id")).Attributes.Add("onmouseover", "someFunction();");    

For SPMenuField, which control should I set the "onmouseover" event to?



When Saving a Page that Contains Javascript, the Content Rendered is Repeated


Each time I save a page that contains javascript, the content rendered is duplicated. For example, I added the following javascript (to display today's date) into a content editor web part:


<script language="JavaScript">
function mdy(todaysdate) {
//calls the function mdy why to get our date
return todaysdate.getMonth()+1+"/"+todaysdate.getDate()+"/"+todaysdate.getYear()
}</script><b><font size="2"><script language="JavaScript">
sampleDate1=new Date()
document.write ("Today's date is "+ mdy(sampleDate1))</script></font></b>


I then click on stop editing. When I go back to edit the page and then click on stop editing, "Todays date is ...." keeps repeating. This happens each time I edit the page.

Has anyone else encountered this problem? If not, do you know what could be causing it?

How do I write a string coming from a Javascript function in my Label control?


Hi all,

This is what I tried doing in my Javascript function (partially):

catch (err) {
              document.getElementById("lblError").innerHTML = err.description;

IE output of my lblError label component is a long id name like this:

<td>Last Error: <span id="ctl00_ctl00_ContentPlaceHolder_GlobalMasterPage_ContentPlaceHolder_DashboardMasterPage_lblError">No errors at this time.</span>

how do I look up for lblLabel in this case?

Thank you

Passing grid DataItem as an argument to javascript function.


in aspx page

<cmp:MenuItemInfo Text="Delete" onclick="javascript:deleteRow('## DataItem.ClientId ##')" />


In Javascript


function deleteRow(rowId)




but the arument is coming as a string '## DataItem.ClientId ##' instead of correct clientID.

Any help ?


Acessing controls in usercontrol in javascript function where user control hosted in webpart



1how to acess controls in usercontrol  in javascript function where user control hosted in webpart


2)How to retieve values from javscript code to server side

details as follows

StringBuilder controlString = new StringBuilder();
            controlString.Append("<p>" + CurrentPage.ToString() + "of " + TotalPages.ToString() + " </p>");
            for (int intIndex = 1; intIndex <= TotalPages; intIndex++)
                controlString.Append("<li><a hre

Finding control from master page inside tabcontainer in content page


I have a codebehind.vb for a master page from which I'm trying to find a hiddenfield in the content page. I was finding it like this without a hitch...

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("hfSearch"), HiddenField)

Then I decided to add an Ajax TabContainer to the content page. Now I'm having a hard time finding the hiddenfield. I've tried these variations, but still not working.

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabContainer1").FindControl("TabPanel1").FindControl("hfSearch"), HiddenField)

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabContainer1").FindControl("hfSearch"), HiddenField)

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabPanel1").FindControl("hfSearch"), HiddenField)

Can someone please help me with the syntax?

Thank you.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend