none
Cómo puedo saber si un checkbox esta activado desde una función de Javascript? RRS feed

  • Question

  • Buenas, quiero verificar si un checkbox esta activado pero como estoy llamando la función desde javascript, no puedo usar el clásico checkBox1.Checked. Pero puedo usar Checkbox pero no se como verificar si el checkBox1 está activado. Ayuda por favor.

               

    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    
            {
    
                webBrowser1.ObjectForScripting = new ScriptInterface();          
            }
       
            [System.Runtime.InteropServices.ComVisibleAttribute(true)]
            public class ScriptInterface
            {
                public void Verify()
                {
                     //MessageBox.Show("");
                    // if (checkBox1.Checked == true) { do something.. }
                               
                }     
            }


    • Edited by Fer Mtz Wednesday, September 25, 2013 11:14 PM
    • Moved by Eason_H Friday, September 27, 2013 6:03 AM
    Wednesday, September 25, 2013 11:10 PM

All replies

  • Translation

    Title:
    How I can tell if a checkbox is activated from a Javascript function?

    Body:
    Good day, I want to check if a checkbox is enabled but as I am calling the function from java, I can not use the classic CheckBox1.Checked. But I can use Checkbox but not as verifying whether the checkBox1 is activated. Help please.

    Response:

    This is a C# forum... please seek a Java forum

    Edit: sorry I see you are doing this from C#

    If the checkbox is in that message box it will not be visible to the code behind until after the postback is complete from that event method... "webBrowser1_DocumentCompleted"

    In other words the message box needs to be already open for that events code to see the check box

    Response Translated back:

    Este es un foro de C # ... por favor busque un foro Java

    Edit: lo siento, veo que está haciendo esto desde C #

    Si la casilla está en ese cuadro de mensaje no será visible para el código subyacente hasta después de la devolución de datos se ha completado a partir de ese método de evento ... "WebBrowser1_DocumentCompleted"

    En otras palabras, el cuadro de mensaje tiene que ser ya abierto para ese código de eventos para ver la casilla de verificación
    • Edited by PaulDAndrea Wednesday, September 25, 2013 11:31 PM
    Wednesday, September 25, 2013 11:15 PM
  • Please read the rest of that post... I corrected myself
    Thursday, September 26, 2013 12:05 AM
  • Translation

    Title:
    How I can tell if a checkbox is activated from a Javascript function?

    Body:
    Good day, I want to check if a checkbox is enabled but as I am calling the function from java, I can not use the classic CheckBox1.Checked. But I can use Checkbox but not as verifying whether the checkBox1 is activated. Help please.

    Response:

    This is a C# forum... please seek a Java forum

    Edit: sorry I see you are doing this from C#

    If the checkbox is in that message box it will not be visible to the code behind until after the postback is complete from that event method... "webBrowser1_DocumentCompleted"

    In other words the message box needs to be already open for that events code to see the check box

    Response Translated back:

    Este es un foro de C # ... por favor busque un foro Java

    Edit: lo siento, veo que está haciendo esto desde C #

    Si la casilla está en ese cuadro de mensaje no será visible para el código subyacente hasta después de la devolución de datos se ha completado a partir de ese método de evento ... "WebBrowser1_DocumentCompleted"

    En otras palabras, el cuadro de mensaje tiene que ser ya abierto para ese código de eventos para ver la casilla de verificación
    This commands are in C#. Not In JAVASCRIPT.. I know that checkbox isn't visible, and how can i do visible that's my principal question.
    Thursday, September 26, 2013 12:07 AM
  • You need to make the checkbox and message box visible before that postback is sent to the code behind.  As far as the code behind is concerned these objects don't exist because when not visible they don't.  You can try setting the style to display:none for those controls...  I've used that trick in the past but unless you try it you wont know if it will work.


    • Edited by PaulDAndrea Thursday, September 26, 2013 12:19 AM
    Thursday, September 26, 2013 12:17 AM
  • Hello,

    The Spanish development forums are on http://social.msdn.microsoft.com/Forums/es-ES/home?category=generaldeves&filter=alltypes&sort=lastpostdesc


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer



    My Blog: http://unlockpowershell.wordpress.com
    My Book: Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

    Wednesday, October 16, 2013 7:03 PM
    Moderator