.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

Tab Control and Javascript

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


I have a Tab Control on a page which I add via Code Behind.

I have a DropDownList on one of the tabs and I wish to add some Javascript to the DropDownList.

With the Javascript I want to put some text 'blah' into a textbox when the DropDownList is changed. 


I try this ...

DropDownList ddlTR14TC2 = new DropDownList();

ddlTR14TC2.Attributes.Add("onChange", "javascript:alert('test - 1050');document.getElementByID('" + tbTR13TC2.ClientID + "').value = 'blah';alert('" + tbTR13TC2.ClientID + "');"

View Complete Post

More Related Resource Links

Content page control passes as argument to javascript function


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

ASCX Control for Javascript



I have created an .ascx control that contains javascript functions.  I have created a Feature that allows me to deploy it to a site collection.

How do I now include that in any page in SharePoint?

I have tried the following:

<asp:Content ID="JScript1" ContentPlaceHolderID="????????" runat="server">
<MyWorkStat:MyWorkStat ID="JScript2" runat="server">


but I don't know what the ContentPlaceHolderID should be set to.


Really I looking for a way to easily inject javascript into SharePoint pages using Features that I can turn on and off. e.g. pieces of javascript that call jQuery functions.


Is there a way?

Accessing Label Control In a listview using Javascript



I have a Button and Label nested inside a ListView.

When a User clicks the button i want the Label to display a specific value eg"Pass". Of course being a Listview the Label value will be relevant to the row the button was clicked on.

I want all this to happen on client side, but i am struggling to access the Label via my Javascript??

Any suggestions and examples Would be much appreciated..

How to conditionally Enable/Disable Button control using JavaScript ?

hi all... i have a Button control & a TextBox control on my web page. The Button control is initially Disabled. I want that while typing into TextBox, when the length of the contents of TextBox reaches to 12 (i.e. when i type 12th character), the Button Control should be Enabled & if the length again comes down to less than 12, the Button control should again be Disabled... How can i do this using JavaScript...?? Does anyone know how to do this...?? Please help. It's urgent... Thanx in advance to all posts !

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! 

How to access ServerSide control Value in Javascript changed by Ajax

Hello,I have a Textbox whose value is been changed using ServerSide code (AJAX based - Partial postback) and now I want to access that changed value in JavaScript. Please suggest me that how can I access that value.document.getElementByID is displaying old value.Things work fine with full postback but are creating above issue with Partial Postback.Thanks, in Advance....

InvalidCastException when calling JavaScript from C# control using a second thread.

Original Issue: I need to be able to call functions in the JavaScript of an HTML page (not ASP.NET) from a C# object embedded in that page.  The c# object has to be .NET 2 level. So I created a C# DLL assembly in VS 2010 which contains a class called NoUIControlClass. set the target framework to .NET 2.0 and made sure to check "Make assembly COM-Visible".  I also signed the assembly so it would have a strong name so I could install it in the GAC.  So far so good. Here is the batch file I run after the project is built to register the control and place it into the GAC: copy "C:\Users\x\Documents\Visual Studio 2010\Projects\NoUIControl\NoUIControl\bin\Debug\NoUIControl.dll" C:\Exploration\NoUIControl C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm NoUIControl.dll /unregister C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm NoUIControl.dll NoUIControl.dll C:\"Program Files (x86)"\"Microsoft SDKs"\Windows\v7.0A\Bin\gacutil.exe /u NoUIControl.dll C:\"Program Files (x86)"\"Microsoft SDKs"\Windows\v7.0A\Bin\gacutil.exe /i NoUIControl.dll This works and all is good.  Next I've turned the security level in IE all the way down for intranet and trusted sites.  Just to make sure that doesn't get in the way.  Here is the HTML file I serve from the web server. <html> <head

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');

embedded javascript in user control

Hello, I would like to know if it is possible to embed javascript in a user control. I've followed this article advices. It works with a custom server control but not with a web user control. Is there something special to do to make it work with user controls ?Moreover, it would be nice that only one javascript reference (<script src=""></script>) figure on the page if I use the same user control several times on the page. Is it possible ? Thanks, mathmax 

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


Referring Control inside datalist from javascript


Hi All,

Problem i am facing in referring textbox control in javascript which is inside Datalist control . i havent found any right solution for the problem if anyone can contribute then i will be very thankfull.

<cc1:lecklabel id="lblnpc" runat="server" token="0" Width="942px" BackColor="SteelBlue" Font-Bold="True" ForeColor="White">Non Production Cost System</cc1<

Find the RootNode text/value of TreeView control using Javascript



Is it possible to find the text/value of the Rootnode  of Treeview control using javascript.



Dynamically adding a javascript control to a row.


Hi all,

I have an old classic asp page that uses a 3rd party javascript calendar control. On that page I dynamically build up controls on a click of a button like so:

function AddContractorRow()
	with (frmMain)
		var objRow = document.all.Table1.insertRow(document.all.Table1.rows.length - 2);

		objRow.style.cursor = "hand";
		objRow.id = "row";

		var objCell = objRow.insertCell();
		objCell.innerHTML = "<input class='mnwInput200' type='text' id='txtTest1' name='txtTest1' value='some val' readonly>";

		var objCell = objRow.insertCell();
		objCell.innerHTML = "<input class='mnwInput200' type='text' id='txtTest2' name='txtTest2' value='some val' readonly>";
		objCell = "";
		objRow = ""


Basically I want to also add this JS control in another cell on the end. Normally to add this control to the page you would just declare it like so:

var calInServiceDate = new ctlSpiffyCalendarBox("calInServiceDate", "frmMain", "datInServiceDate","btnInServiceDate","<%=Date()%>");


Then the markup is just:

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?



problem with user control+update panel+javascript


hai all,


Im having a aspx page which has 5 tabs inside a update panel..also I have a user control

Wen I click each tab im dynamically loading dat user control .

The problem is im using javascript in dat user control..

the user control has a button which displays a panel containing three grid views  n s activated by a java script as given below..

function Elig()



'<%=btnLegend.ClientID %>')).click(function(){


('<%=pBody.ClientID %>')).slideToggle('slow');




Wen i run the aspx page the first tab  successfully loaded with dat user control n a

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