problems with client scripting invoked from DataGrid OnItemDataBoundEvent

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Hello,

    I have the following problem:
    I have a DataGrid control on my page with a column with TextBox controls and
    another one with ImageButton controls. In order to force a call to
    JavaScript client-side script when ImageButton is pressed, I added the
    following code to OnItemDataBoundEvent (check for Item Types not shown
    here):

    Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
    Dim imgbtKosarica As ImageButton =
    e.Item.Cells(7).FindControl("imgbtKosarica")
    imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    tbKolicina.Text & "')")

    "tbKolicina" is the TextBox control whose value I want to pass to JavaScript
    for validation when ImageButton called "imgbtKosarica" is clicked.
    JavaScript is currently just an elementary script (no validation yet) and
    should simply display an alert box with the passed parameter
    (tbKolicinaText) displayed when the ImageButton is clicked.

    It works fine (finds the controls and calls the JavaScript) up to one final
    point: the value of the TextBox (tbKolicina.text) doesn't reach the
    JavaScript script. Whatever I write into the TextBox, I receive an empty
    alert box. But, if I set the value for the tbKolicina.text programatically,
    that value does get passed. I concluded therefore that only the initial
    value reaches JavaScript.

    What did I do wrong and how could I make this validation work?

    Thank you in advance,
    Hrvoje


    Hrvoje Vrbanc Guest

  2. Similar Questions and Discussions

    1. How to prevent our client from using Scripting.FileSystemObject
      I offer web space for our client to host their website. We offer them to upload asp files. How can we prevent our client to upload asp files wSet...
    2. Help needed with DataGrid Client-Side Scripting
      Hi, I have a custom ASP.Net DataGrid Control which has DropDownLists in each of the HeaderCells of the Grid. I'm not able to get the ClientID...
    3. Client side and server side scripting problem
      Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve...
    4. Scripting.FileSystemObject problems
      If I comment #2 to #5 no problems. If I uncomment #2, #4 and #5 the page hangs. Even did not reach the point to uncomment #3 So, whats wrong. Do i...
    5. Getting the name of an invoked method?
      Hello, In the C Ruby API, is there a clean way to get the name of the method which has been invoked? ie. If there is a single C function...
  3. #2

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Hi

    This should pass the value of tbKolicina field to the function
    imgbtKosarica.Attributes.Add("onclick", "return
    validacija(this.form.tbKolicina.value)")

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > Hello,
    >
    > I have the following problem:
    > I have a DataGrid control on my page with a column with TextBox controls
    and
    > another one with ImageButton controls. In order to force a call to
    > JavaScript client-side script when ImageButton is pressed, I added the
    > following code to OnItemDataBoundEvent (check for Item Types not shown
    > here):
    >
    > Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
    > Dim imgbtKosarica As ImageButton =
    > e.Item.Cells(7).FindControl("imgbtKosarica")
    > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > tbKolicina.Text & "')")
    >
    > "tbKolicina" is the TextBox control whose value I want to pass to
    JavaScript
    > for validation when ImageButton called "imgbtKosarica" is clicked.
    > JavaScript is currently just an elementary script (no validation yet) and
    > should simply display an alert box with the passed parameter
    > (tbKolicinaText) displayed when the ImageButton is clicked.
    >
    > It works fine (finds the controls and calls the JavaScript) up to one
    final
    > point: the value of the TextBox (tbKolicina.text) doesn't reach the
    > JavaScript script. Whatever I write into the TextBox, I receive an empty
    > alert box. But, if I set the value for the tbKolicina.text
    programatically,
    > that value does get passed. I concluded therefore that only the initial
    > value reaches JavaScript.
    >
    > What did I do wrong and how could I make this validation work?
    >
    > Thank you in advance,
    > Hrvoje
    >
    >

    Vidar Petursson Guest

  4. #3

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Vidar,

    thank you for the advice.
    Unfortunately, it still doesn't work - it displays error message within the
    alert box: "'this.form.tbKolicina.value' is null or not an
    object"....somehow it doesn't recognize it.

    Hrvoje


    "Vidar Petursson" <theking@icysoft.com> wrote in message
    news:OYZX$oaXDHA.888@TK2MSFTNGP10.phx.gbl...
    > Hi
    >
    > This should pass the value of tbKolicina field to the function
    > imgbtKosarica.Attributes.Add("onclick", "return
    > validacija(this.form.tbKolicina.value)")
    >
    > --
    > Best Regards
    > Vidar Petursson
    > ==============================
    > Microsoft Internet Client & Controls MVP
    > ==============================
    > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > > Hello,
    > >
    > > I have the following problem:
    > > I have a DataGrid control on my page with a column with TextBox controls
    > and
    > > another one with ImageButton controls. In order to force a call to
    > > JavaScript client-side script when ImageButton is pressed, I added the
    > > following code to OnItemDataBoundEvent (check for Item Types not shown
    > > here):
    > >
    > > Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
    > > Dim imgbtKosarica As ImageButton =
    > > e.Item.Cells(7).FindControl("imgbtKosarica")
    > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > > tbKolicina.Text & "')")
    > >
    > > "tbKolicina" is the TextBox control whose value I want to pass to
    > JavaScript
    > > for validation when ImageButton called "imgbtKosarica" is clicked.
    > > JavaScript is currently just an elementary script (no validation yet)
    and
    > > should simply display an alert box with the passed parameter
    > > (tbKolicinaText) displayed when the ImageButton is clicked.
    > >
    > > It works fine (finds the controls and calls the JavaScript) up to one
    > final
    > > point: the value of the TextBox (tbKolicina.text) doesn't reach the
    > > JavaScript script. Whatever I write into the TextBox, I receive an empty
    > > alert box. But, if I set the value for the tbKolicina.text
    > programatically,
    > > that value does get passed. I concluded therefore that only the initial
    > > value reaches JavaScript.
    > >
    > > What did I do wrong and how could I make this validation work?
    > >
    > > Thank you in advance,
    > > Hrvoje
    > >
    > >
    >
    >

    Hrvoje Vrbanc Guest

  5. #4

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Hi

    Make sure the field is there and you have the name spelled correctly ( case
    sensitive )

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    news:uNYA4waXDHA.1384@TK2MSFTNGP10.phx.gbl...
    > Vidar,
    >
    > thank you for the advice.
    > Unfortunately, it still doesn't work - it displays error message within
    the
    > alert box: "'this.form.tbKolicina.value' is null or not an
    > object"....somehow it doesn't recognize it.
    >
    > Hrvoje
    >
    >
    > "Vidar Petursson" <theking@icysoft.com> wrote in message
    > news:OYZX$oaXDHA.888@TK2MSFTNGP10.phx.gbl...
    > > Hi
    > >
    > > This should pass the value of tbKolicina field to the function
    > > imgbtKosarica.Attributes.Add("onclick", "return
    > > validacija(this.form.tbKolicina.value)")
    > >
    > > --
    > > Best Regards
    > > Vidar Petursson
    > > ==============================
    > > Microsoft Internet Client & Controls MVP
    > > ==============================
    > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > > > Hello,
    > > >
    > > > I have the following problem:
    > > > I have a DataGrid control on my page with a column with TextBox
    controls
    > > and
    > > > another one with ImageButton controls. In order to force a call to
    > > > JavaScript client-side script when ImageButton is pressed, I added the
    > > > following code to OnItemDataBoundEvent (check for Item Types not shown
    > > > here):
    > > >
    > > > Dim tbKolicina As TextBox = e.Item.Cells(6).FindControl("tbKolicina")
    > > > Dim imgbtKosarica As ImageButton =
    > > > e.Item.Cells(7).FindControl("imgbtKosarica")
    > > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > > > tbKolicina.Text & "')")
    > > >
    > > > "tbKolicina" is the TextBox control whose value I want to pass to
    > > JavaScript
    > > > for validation when ImageButton called "imgbtKosarica" is clicked.
    > > > JavaScript is currently just an elementary script (no validation yet)
    > and
    > > > should simply display an alert box with the passed parameter
    > > > (tbKolicinaText) displayed when the ImageButton is clicked.
    > > >
    > > > It works fine (finds the controls and calls the JavaScript) up to one
    > > final
    > > > point: the value of the TextBox (tbKolicina.text) doesn't reach the
    > > > JavaScript script. Whatever I write into the TextBox, I receive an
    empty
    > > > alert box. But, if I set the value for the tbKolicina.text
    > > programatically,
    > > > that value does get passed. I concluded therefore that only the
    initial
    > > > value reaches JavaScript.
    > > >
    > > > What did I do wrong and how could I make this validation work?
    > > >
    > > > Thank you in advance,
    > > > Hrvoje
    > > >
    > > >
    > >
    > >
    >
    >

    Vidar Petursson Guest

  6. #5

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Hello and thank you, John.

    As alert box shows, nothing was put in JavaScript, i.e., the source says
    onclick="return validacija('')", just as if the text box was empty (no value
    for the parameter). Funny, but the same source shows correct value in the
    text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
    type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the
    entered number that doesn't reach the JavaScript....
    Funny!

    Hrvoje


    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:#L08TIbXDHA.2632@TK2MSFTNGP09.phx.gbl...
    > Hrvoje,
    >
    > Take a look at the generated HTML with View Source in IE. Look to see what
    > was put into your JavaScript.
    > -- .e.
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > news:uNYA4waXDHA.1384@TK2MSFTNGP10.phx.gbl...
    > > Vidar,
    > >
    > > thank you for the advice.
    > > Unfortunately, it still doesn't work - it displays error message within
    > the
    > > alert box: "'this.form.tbKolicina.value' is null or not an
    > > object"....somehow it doesn't recognize it.
    > >
    > > Hrvoje
    > >
    > >
    > > "Vidar Petursson" <theking@icysoft.com> wrote in message
    > > news:OYZX$oaXDHA.888@TK2MSFTNGP10.phx.gbl...
    > > > Hi
    > > >
    > > > This should pass the value of tbKolicina field to the function
    > > > imgbtKosarica.Attributes.Add("onclick", "return
    > > > validacija(this.form.tbKolicina.value)")
    > > >
    > > > --
    > > > Best Regards
    > > > Vidar Petursson
    > > > ==============================
    > > > Microsoft Internet Client & Controls MVP
    > > > ==============================
    > > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > > news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > > > > Hello,
    > > > >
    > > > > I have the following problem:
    > > > > I have a DataGrid control on my page with a column with TextBox
    > controls
    > > > and
    > > > > another one with ImageButton controls. In order to force a call to
    > > > > JavaScript client-side script when ImageButton is pressed, I added
    the
    > > > > following code to OnItemDataBoundEvent (check for Item Types not
    shown
    > > > > here):
    > > > >
    > > > > Dim tbKolicina As TextBox =
    e.Item.Cells(6).FindControl("tbKolicina")
    > > > > Dim imgbtKosarica As ImageButton =
    > > > > e.Item.Cells(7).FindControl("imgbtKosarica")
    > > > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > > > > tbKolicina.Text & "')")
    > > > >
    > > > > "tbKolicina" is the TextBox control whose value I want to pass to
    > > > JavaScript
    > > > > for validation when ImageButton called "imgbtKosarica" is clicked.
    > > > > JavaScript is currently just an elementary script (no validation
    yet)
    > > and
    > > > > should simply display an alert box with the passed parameter
    > > > > (tbKolicinaText) displayed when the ImageButton is clicked.
    > > > >
    > > > > It works fine (finds the controls and calls the JavaScript) up to
    one
    > > > final
    > > > > point: the value of the TextBox (tbKolicina.text) doesn't reach the
    > > > > JavaScript script. Whatever I write into the TextBox, I receive an
    > empty
    > > > > alert box. But, if I set the value for the tbKolicina.text
    > > > programatically,
    > > > > that value does get passed. I concluded therefore that only the
    > initial
    > > > > value reaches JavaScript.
    > > > >
    > > > > What did I do wrong and how could I make this validation work?
    > > > >
    > > > > Thank you in advance,
    > > > > Hrvoje
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    vrba Guest

  7. #6

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    I just took a quick look back at your code. You're taking the value out of
    the TextBox in OnItemDataBound, but when did you put a value _into_ the
    TextBox?
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]

    "vrba" <hrvojev@recro.hr> wrote in message
    news:OCRbAodXDHA.1580@tk2msftngp13.phx.gbl...
    > Hello and thank you, John.
    >
    > As alert box shows, nothing was put in JavaScript, i.e., the source says
    > onclick="return validacija('')", just as if the text box was empty (no
    value
    > for the parameter). Funny, but the same source shows correct value in the
    > text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
    > type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being the
    > entered number that doesn't reach the JavaScript....
    > Funny!
    >
    > Hrvoje
    >
    >
    > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > news:#L08TIbXDHA.2632@TK2MSFTNGP09.phx.gbl...
    > > Hrvoje,
    > >
    > > Take a look at the generated HTML with View Source in IE. Look to see
    what
    > > was put into your JavaScript.
    > > -- .e.
    > > John Saunders
    > > Internet Engineer
    > > [email]john.saunders@surfcontrol.com[/email]
    > >
    > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > news:uNYA4waXDHA.1384@TK2MSFTNGP10.phx.gbl...
    > > > Vidar,
    > > >
    > > > thank you for the advice.
    > > > Unfortunately, it still doesn't work - it displays error message
    within
    > > the
    > > > alert box: "'this.form.tbKolicina.value' is null or not an
    > > > object"....somehow it doesn't recognize it.
    > > >
    > > > Hrvoje
    > > >
    > > >
    > > > "Vidar Petursson" <theking@icysoft.com> wrote in message
    > > > news:OYZX$oaXDHA.888@TK2MSFTNGP10.phx.gbl...
    > > > > Hi
    > > > >
    > > > > This should pass the value of tbKolicina field to the function
    > > > > imgbtKosarica.Attributes.Add("onclick", "return
    > > > > validacija(this.form.tbKolicina.value)")
    > > > >
    > > > > --
    > > > > Best Regards
    > > > > Vidar Petursson
    > > > > ==============================
    > > > > Microsoft Internet Client & Controls MVP
    > > > > ==============================
    > > > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > > > news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > > > > > Hello,
    > > > > >
    > > > > > I have the following problem:
    > > > > > I have a DataGrid control on my page with a column with TextBox
    > > controls
    > > > > and
    > > > > > another one with ImageButton controls. In order to force a call to
    > > > > > JavaScript client-side script when ImageButton is pressed, I added
    > the
    > > > > > following code to OnItemDataBoundEvent (check for Item Types not
    > shown
    > > > > > here):
    > > > > >
    > > > > > Dim tbKolicina As TextBox =
    > e.Item.Cells(6).FindControl("tbKolicina")
    > > > > > Dim imgbtKosarica As ImageButton =
    > > > > > e.Item.Cells(7).FindControl("imgbtKosarica")
    > > > > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > > > > > tbKolicina.Text & "')")
    > > > > >
    > > > > > "tbKolicina" is the TextBox control whose value I want to pass to
    > > > > JavaScript
    > > > > > for validation when ImageButton called "imgbtKosarica" is clicked.
    > > > > > JavaScript is currently just an elementary script (no validation
    > yet)
    > > > and
    > > > > > should simply display an alert box with the passed parameter
    > > > > > (tbKolicinaText) displayed when the ImageButton is clicked.
    > > > > >
    > > > > > It works fine (finds the controls and calls the JavaScript) up to
    > one
    > > > > final
    > > > > > point: the value of the TextBox (tbKolicina.text) doesn't reach
    the
    > > > > > JavaScript script. Whatever I write into the TextBox, I receive an
    > > empty
    > > > > > alert box. But, if I set the value for the tbKolicina.text
    > > > > programatically,
    > > > > > that value does get passed. I concluded therefore that only the
    > > initial
    > > > > > value reaches JavaScript.
    > > > > >
    > > > > > What did I do wrong and how could I make this validation work?
    > > > > >
    > > > > > Thank you in advance,
    > > > > > Hrvoje
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    John Saunders Guest

  8. #7

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    Hello John,
    hm, I thought that OnItemDataBound I just wire the script and that values
    could be transferred later.....obviously a mistake. I was thinking about
    that but if I put my code inside OnSelectedIndexChanged event, then the page
    doesn't react on the first click (because only then is the script activated)
    but only when the same ImageButton is clicked for the second time....
    Therefore, it seems I need the new solution.

    Thank you,
    Hrvoje

    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:uVjYaLeXDHA.2312@TK2MSFTNGP10.phx.gbl...
    > I just took a quick look back at your code. You're taking the value out of
    > the TextBox in OnItemDataBound, but when did you put a value _into_ the
    > TextBox?
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    > "vrba" <hrvojev@recro.hr> wrote in message
    > news:OCRbAodXDHA.1580@tk2msftngp13.phx.gbl...
    > > Hello and thank you, John.
    > >
    > > As alert box shows, nothing was put in JavaScript, i.e., the source says
    > > onclick="return validacija('')", just as if the text box was empty (no
    > value
    > > for the parameter). Funny, but the same source shows correct value in
    the
    > > text box parameters, e.g. <input name="dgProdukti:_ctl4:tbKolicina"
    > > type="text" value="711" id="dgProdukti__ctl4_tbKolicina" />, 711 being
    the
    > > entered number that doesn't reach the JavaScript....
    > > Funny!
    > >
    > > Hrvoje
    > >
    > >
    > > "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    > > news:#L08TIbXDHA.2632@TK2MSFTNGP09.phx.gbl...
    > > > Hrvoje,
    > > >
    > > > Take a look at the generated HTML with View Source in IE. Look to see
    > what
    > > > was put into your JavaScript.
    > > > -- .e.
    > > > John Saunders
    > > > Internet Engineer
    > > > [email]john.saunders@surfcontrol.com[/email]
    > > >
    > > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > > news:uNYA4waXDHA.1384@TK2MSFTNGP10.phx.gbl...
    > > > > Vidar,
    > > > >
    > > > > thank you for the advice.
    > > > > Unfortunately, it still doesn't work - it displays error message
    > within
    > > > the
    > > > > alert box: "'this.form.tbKolicina.value' is null or not an
    > > > > object"....somehow it doesn't recognize it.
    > > > >
    > > > > Hrvoje
    > > > >
    > > > >
    > > > > "Vidar Petursson" <theking@icysoft.com> wrote in message
    > > > > news:OYZX$oaXDHA.888@TK2MSFTNGP10.phx.gbl...
    > > > > > Hi
    > > > > >
    > > > > > This should pass the value of tbKolicina field to the function
    > > > > > imgbtKosarica.Attributes.Add("onclick", "return
    > > > > > validacija(this.form.tbKolicina.value)")
    > > > > >
    > > > > > --
    > > > > > Best Regards
    > > > > > Vidar Petursson
    > > > > > ==============================
    > > > > > Microsoft Internet Client & Controls MVP
    > > > > > ==============================
    > > > > > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > > > > > news:%23RYeHfaXDHA.1644@TK2MSFTNGP10.phx.gbl...
    > > > > > > Hello,
    > > > > > >
    > > > > > > I have the following problem:
    > > > > > > I have a DataGrid control on my page with a column with TextBox
    > > > controls
    > > > > > and
    > > > > > > another one with ImageButton controls. In order to force a call
    to
    > > > > > > JavaScript client-side script when ImageButton is pressed, I
    added
    > > the
    > > > > > > following code to OnItemDataBoundEvent (check for Item Types not
    > > shown
    > > > > > > here):
    > > > > > >
    > > > > > > Dim tbKolicina As TextBox =
    > > e.Item.Cells(6).FindControl("tbKolicina")
    > > > > > > Dim imgbtKosarica As ImageButton =
    > > > > > > e.Item.Cells(7).FindControl("imgbtKosarica")
    > > > > > > imgbtKosarica.Attributes.Add("onClick", "return validacija('" &
    > > > > > > tbKolicina.Text & "')")
    > > > > > >
    > > > > > > "tbKolicina" is the TextBox control whose value I want to pass
    to
    > > > > > JavaScript
    > > > > > > for validation when ImageButton called "imgbtKosarica" is
    clicked.
    > > > > > > JavaScript is currently just an elementary script (no validation
    > > yet)
    > > > > and
    > > > > > > should simply display an alert box with the passed parameter
    > > > > > > (tbKolicinaText) displayed when the ImageButton is clicked.
    > > > > > >
    > > > > > > It works fine (finds the controls and calls the JavaScript) up
    to
    > > one
    > > > > > final
    > > > > > > point: the value of the TextBox (tbKolicina.text) doesn't reach
    > the
    > > > > > > JavaScript script. Whatever I write into the TextBox, I receive
    an
    > > > empty
    > > > > > > alert box. But, if I set the value for the tbKolicina.text
    > > > > > programatically,
    > > > > > > that value does get passed. I concluded therefore that only the
    > > > initial
    > > > > > > value reaches JavaScript.
    > > > > > >
    > > > > > > What did I do wrong and how could I make this validation work?
    > > > > > >
    > > > > > > Thank you in advance,
    > > > > > > Hrvoje
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Hrvoje Vrbanc Guest

  9. #8

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    news:%23FBgxLlXDHA.3268@tk2msftngp13.phx.gbl...
    > Hello John,
    > hm, I thought that OnItemDataBound I just wire the script and that values
    > could be transferred later.....obviously a mistake.
    Nope. In OnItemDataBound you're supposed to bind data to the controls in the
    item if they don't do that on their own. For instance, I have an employee
    list datagrid with a Delete LinkButton in it. I use ItemDataBound to set the
    JavaScript which displays the confirm dialog, and I take the opportunity to
    concatenate the first and last name of the employee being deleted. I have a
    HyperLink control in the same grid, and I set the NavigateUrl in the
    ItemDataBound event to include the employee ID in the query string of the
    URL.

    So, I use it for things which are too complicated for a databinding
    expression to handle, or for things where the databinding expression is
    simply too complicated or ugly to look at in the .aspx file. I move it into
    the .aspx.cs file where nobody needs to see it!
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    John Saunders Guest

  10. #9

    Default Re: problems with client scripting invoked from DataGrid OnItemDataBoundEvent

    I understand.
    But what is the solution for my problems then (a rhetorical question :-))?

    Hrvoje


    "John Saunders" <john.saunders@surfcontrol.com> wrote in message
    news:#xTE3slXDHA.388@TK2MSFTNGP10.phx.gbl...
    > "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    > news:%23FBgxLlXDHA.3268@tk2msftngp13.phx.gbl...
    > > Hello John,
    > > hm, I thought that OnItemDataBound I just wire the script and that
    values
    > > could be transferred later.....obviously a mistake.
    >
    > Nope. In OnItemDataBound you're supposed to bind data to the controls in
    the
    > item if they don't do that on their own. For instance, I have an employee
    > list datagrid with a Delete LinkButton in it. I use ItemDataBound to set
    the
    > JavaScript which displays the confirm dialog, and I take the opportunity
    to
    > concatenate the first and last name of the employee being deleted. I have
    a
    > HyperLink control in the same grid, and I set the NavigateUrl in the
    > ItemDataBound event to include the employee ID in the query string of the
    > URL.
    >
    > So, I use it for things which are too complicated for a databinding
    > expression to handle, or for things where the databinding expression is
    > simply too complicated or ugly to look at in the .aspx file. I move it
    into
    > the .aspx.cs file where nobody needs to see it!
    > --
    > John Saunders
    > Internet Engineer
    > [email]john.saunders@surfcontrol.com[/email]
    >
    >

    Hrvoje Vrbanc Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139