H
Hrvoje Vrbanc
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
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