.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

How to change a value in the usercontrol through javascript

Posted By:      Posted Date: September 11, 2010    Points: 0   Category :ASP.Net
Hello,   I am trying to create a modalpopup user control using ModalPopup extender from the AjaxToolkit and a usercontrol, so that I could show a modal popup window on several pages, simply using the single user control. It will be shown whenevr a button is clicked and certain amount of work is done on the server side, say a "Save" button is clicked, the data is successfully saved in the database and then the modalpopu is shown. The website also has a master page. The title and the content has to be changed, depending upon which button on which page is clicked, or wheter the save was successful or not. I am having problem in changing them through code. I tried to use ScriptManager.RegisterClientScriptBlock to send the title and content values and try to execute a javascript on the master page, but the two controls on the user control come as null when I try to access them from js using the getElementById method. The following is the code:The usercontrol: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ModalPopup.ascx.cs" Inherits="Modal.Controls.ModalPopup" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> <div> <asp:Button ID="Button1" style="display:none" runa

View Complete Post

More Related Resource Links

dropdownlist javascript change items


I can't find solution for this problem for very long time:

I have dropdownlists in Gridview. I need to dinamicly change content of dropdown on client with javascript. Ok, I know to do that. But the problem is when I send data to server changes in dropdownlist does not see. On server I have  old items. How can I change items in dropdown on client with javascript and than see that items on sever when postback data?


change form target from javascript


Salam to all,

in my page, i have an iframe which have a src for another page,

the inner page have a Forms, buttons.. ..etc. the target for the form in the inner page is "self"

i need to run a javascript code from the parent page to change the  inner page form target to posted the values in a Blank window.

how can i do that ?


Change RadMaskedTextBox value via javascript

Hi All,I am using RadMaskedTextBox in my web page. I am trying to set its value through javascript. It works ok if i hard-code control name (i.e. rtHours11_1) in the script as following: var radMaskedTextBox1 = window["<%= rtHours11_1.ClientID %>"]; radMaskedTextBox1.SetValue("00:00"); But I want to set the control name dynamically as this function will be called for many controls on the page. Can someone help me to modify it in the way that it will accept the control name dynamically as following: function InitilizeMe(thisCtrl) { var radMaskedTextBox1 = window["<%= thisCtrl.ClientID %>"];  radMaskedTextBox1.SetValue("00:00"); } Thanks in advance for your help.Regards.

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

Change active tab in Ajax tab container using javascript

I have been using the ajax tab control. I need to change the active tab index of the tab container through javascript. Can please anyone tell me how can i do it Cheers Sohail Sayed

Trap Selected Index change event of listbox using Javascript.

Hi All, This is reagarding listbox selection. I have a list box with multi select option. I want to trap the selected index change event of Listbox through javascript. Item of list box can be selected using Click of mouse and also the keyboard up down key with shift. I tried onclick event to bind the javascript function. It works fine if I select by mouse, but it doesen't work for up/down key of keyboard. Thanks, Naveen

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?

Silverlight media player change source and play from javascript

I am having trouble accessing an embedded Silverlight 2 media player in an aspx page from Javascript and was hoping someone might offer some insight on what's going on. What I want to do is fire a javascript event on the client when a button is pressed to change the Silverlight media player media source and then play the newly selected file. I found what seemed like a pretty straightforward example on the silverlight.net site that looked like this:<%@ Page Title="" Language="VB" MasterPageFile="~/master.master" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %> <%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %> <asp:Content ID="Content1" ContentPlaceHolderID="Middle" Runat="Server"> <asp:MediaPlayer ID="Media1" runat="server" Height="240px" Width="320px"> </asp:MediaPlayer> <button id="Button1" onclick="onPlay()" type="button">Play</button> <script type="text/javascript"> function onPlay() { try { var player = $find("ctl00_Middle_Media1"); player.set_mediasource("example.mp3");

change URL using javascript, but URL doesnt change

I want to redirect a user to an url after he clicks a checkbox using javascript.I succeed at doing that using this code:<input id="partylocation" type="checkbox" onclick="javascript:location.href='www.domain.com/?q=party';" />HOWEVER: the URL remains the same! I need the URL to change accoding to the new domain.I also tried:<input id="partylocation" type="checkbox" onclick="javascript:window.location='www.domain.com/?q=party';" />

Can we change the "specify your own value" Text when you are using fill-in choice using javascript?


Can we change the "specify your own value" Text when you are using fill-in choice using javascript?

I need to change the text? If you guys know anything on this, let me know. 


Change selected row background color in gridview using javascript


hi frineds,

              i have a gridview with radio buttons in gridview i have chance to select only one item at a time in gridview like this

i need to change the row color of selected item in gridview with radio button using javascript if i select second row with radio button first row comes to normal condition now second row is in selected mode please help to write this functionality using javascript

How to change the page(aspx) title from Usercontrol(ascx) the inside the page(aspx) (asp.net 1.1) ??




I have user control(ascx) inside  the page(aspx) and from the code behind of that user control How can I change the page(aspx) title??


Note : Please my Question about asp.net 1.1


And thanks with my best regarding


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

How to change a label.text from Javascript?



I got a regular Javascript.

How to change a label.text from a javascript?

Thanks, Gil.

Access control within a usercontrol from Javascript


I have a javascript embedded in my extended gridview control that reference the grid control. Example:

var DataGridObj = document.getElementById(GridView1);


where GridView1 is a variable and my calling program passes the grid name. This is ok if I place my extended gridview on aspx page and run. But, how if, I have gridview in a user control and that user control is being used in aspx?

My ASPX -> My User Control -> Extended GridView.

When I check the html code, my gridview has an ID of "UserControlID_ExtendedGridViewID". Example:

In Default.aspx

<uc1:MyGrid ID="MyGrid1" runat="server" />

In UserControl (MyGrid.ascx)

<cc1:ExtendedGridView ID="GridView1" runat="server" DataSourceID="XmlDataSource1" </cc1:GridView>

and, finally in ExtendedGridView.cs

function CreateGridHeader(DataDiv, GridView1, HeaderDiv) 
    var DataGridObj = document.getElementById(GridView1);
//other part of code

HTML code:

<table cellspacing="0" rules="all" border="0" id="MyGrid1_GridView1&q

Text Change for Text Box not firing when changing the text from Javascript




I have a web page on which  I show a popup window on a button click which on closing updates text in a textbox on my webpage, I have text change event on this text box, this event is geting fired when I type something in text box and come out but its not firing when the text is change by my javascript function which is called by the popup window, anybody faced similar issues? please let me know how to handle this!!


thanks in advance



UserControl: Change image and play sound on MouseDown using only XAML?



I am trying to develop a UserContorl which shows an image that changes and plays a sound when MouseDown is raised. This is my UserControl:


<UserControl x:Class="Jugues.contacteButton"
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