Javascript and asp.net datagrid controls

Discussion in 'Javascript' started by tshad, Jul 20, 2006.

  1. tshad

    tshad Guest

    I need to do some work with Javascript and my datagrid controls.

    I want to do something like:
    *********************************************************
    function CheckQuestion()
    {
    var checkBox = document.getElementById('_ctl0_SecurityStandard');
    if (checkBox.checked)
    {
    dropDown = document.getElementById('_ctl0_SecretQuestion');
    dropDown.disabled = false;
    textBox = document.getElementById('_ctl0_SecretQuestionText');
    textBox.value = "";
    textBox.disabled = true;
    }
    else
    {
    dropDown = document.getElementById('_ctl0_SecretQuestion');
    dropDown.disabled = true;
    textBox = document.getElementById('_ctl0_SecretQuestionText');
    textBox.disabled = false;
    }
    }
    ***************************************************************

    The actual names are SecurityStandard, not _ct10_SecurityStandard.

    This works fine if I know the actual name of the object.

    But in a Datagrid I get something like:

    <input id="JobBoardsGrid__ctl2_JobBoard" type="checkbox"
    name="JobBoardsGrid:_ctl2:JobBoard" onclick="Javascript:CheckQuestion();" />

    and the next row will be:

    <input id="JobBoardsGrid__ctl3_JobBoard" type="checkbox"
    name="JobBoardsGrid:_ctl3:JobBoard" onclick="Javascript:CheckQuestion();" />

    Is there a way to know what object is calling, what the name is and by
    that, I could prepend the extra part to the name of all the other objects in
    that DataGridItem?

    I am setting up the object to call the function from an AttachScript from
    the DataGrid
    *******************************************************************
    Sub OnAttachScript(sender as Object, e as DataGridItemEventArgs)
    if e.Item.ItemType = ListItemType.ITem Or _
    e.Item.ItemType = ListItemType.AlternatingItem then
    Dim oImageButton as CheckBox = CType(e.Item.FindControl("JobBoard"),
    CheckBox)
    oImageButton.Attributes.Add ("onClick","Javascript:CheckQuestion();")
    end if
    end Sub
    *******************************************************************************

    Thanks,

    Tom
     
    tshad, Jul 20, 2006
    #1
    1. Advertising

  2. tshad

    Matt Kruse Guest

    tshad wrote:
    > But in a Datagrid I get something like:
    > <input id="JobBoardsGrid__ctl2_JobBoard" type="checkbox"
    > name="JobBoardsGrid:_ctl2:JobBoard"
    > onclick="Javascript:CheckQuestion();" />


    I would not use technology that auto-generated javascript code in such a
    clueless manner.

    --
    Matt Kruse
    http://www.JavascriptToolbox.com
    http://www.AjaxToolbox.com
     
    Matt Kruse, Jul 20, 2006
    #2
    1. Advertising

  3. tshad

    Randy Webb Guest

    tshad said the following on 7/20/2006 5:55 PM:
    > Nevermind.
    >
    > I figured it out.


    No you didn't.

    > ....onclick="Javascript"CheckQuestion(this);"


    Answer:It destroys the order of the conversation
    Question: Why?
    Answer: Top-Posting.
    Question: Whats the most annoying thing on Usenet?

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Jul 20, 2006
    #3
  4. tshad

    tshad Guest

    "Randy Webb" <> wrote in message
    news:...
    > tshad said the following on 7/20/2006 5:55 PM:
    >> Nevermind.
    >>
    >> I figured it out.

    >
    > No you didn't.
    >


    Actually, I did. I just typed it in wrong.

    oImageButton.Attributes.Add ("onClick","Javascript:CheckJobBoard(this);")

    This does work.

    Tom
    >> ....onclick="Javascript"CheckQuestion(this);"

    >
    > Answer:It destroys the order of the conversation
    > Question: Why?
    > Answer: Top-Posting.
    > Question: Whats the most annoying thing on Usenet?
    >
    > --
    > Randy
    > comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    > Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
    > Javascript Best Practices -
    > http://www.JavascriptToolbox.com/bestpractices/
     
    tshad, Jul 21, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leszek
    Replies:
    4
    Views:
    2,058
    Leszek
    Aug 20, 2003
  2. dx
    Replies:
    10
    Views:
    955
    John Saunders
    Apr 11, 2004
  3. =?Utf-8?B?SmltIEhlYXZleQ==?=

    ASP.Net Controls and Javascript

    =?Utf-8?B?SmltIEhlYXZleQ==?=, Dec 21, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    2,762
    willk
    May 27, 2007
  4. Bob Rock
    Replies:
    1
    Views:
    665
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
  5. Nathan Sokalski
    Replies:
    4
    Views:
    1,156
    Muhammad Naveed Yaseen
    Sep 5, 2007
Loading...

Share This Page