.NET accessing and setting a DetailsView hidden textbox in JavaScript

Posted on 2006-05-16
Last Modified: 2008-02-01

Please tell me how to access the DetailsView hiddentext box in my javascript function below:

function setcheckboxvalidate(){

CheckBox cb11 = document.getElementByID("cb1") ;

 if(cb11.Checked)  DetailsView1.hiddentextbox1="true"
else  DetailsView1.hiddentextbox1=null


In my code behind I have this for the checkbox: ( have not tested the cb1.ClientID? which is new to me?)

CheckBox cb1 = (CheckBox) DetailsView1.FindControl("CheckBox1");
cb1.Attributes.Add("OnClick", "javascript:setcheckboxvalidate('" + cb1.ClientID + "');");

Thank you for any and all input here!!!!!!

Question by:RSSIAdmin
    LVL 27

    Accepted Solution

    change CheckBox cb11 = document.getElementByID("cb1") ; to var cb11 = document.getElementById("cb1");

    Note: Javascript is case sensitive and you have getElementByID instead of getElementById

    The ClientID is the ID created by when the control is served to the client "Browser"
    if you create a textbox and call it textbox2, once you serve the page to the client, it will be served as <input name="TextBox2" type="text" id="TextBox2" />


    Author Comment

    sammy1971...... Great before I give an A

    Please..... show me the correct way to do the following as it relates to setting the value of the DetailsView1.hiddentextbox1????  will this work:

    if(cb11.Checked)  DetailsView1.hiddentextbox1="true"
    else  DetailsView1.hiddentextbox1=null

    I am assuming is similar to var cb11 = document.getElementById("cb1");

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    This video discusses moving either the default database or any database to a new volume.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now