从DataGrid OnItemDataBoundEvent调用的客户端脚本问题 [英] problems with client scripting invoked from DataGrid OnItemDataBoundEvent

查看:54
本文介绍了从DataGrid OnItemDataBoundEvent调用的客户端脚本问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有以下问题:

我的页面上有一个DataGrid控件,带有TextBox控件的列和

另一个带有ImageButton控件的人。为了在按下ImageButton时强制调用

JavaScript客户端脚本,我将以下代码中的

添加到OnItemDataBoundEvent(检查项类型未显示

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"是TextBox控件,当ImageButton调用imgbtKosarica时,我想将其值传递给JavaScript

进行验证。单击。

JavaScript目前只是一个基本脚本(尚未验证)和

应该只显示一个带有传递参数的警告框

单击ImageButton时显示(tbKolicinaText)。


它工作正常(找到控件并调用JavaScript)最多一个

点:值TextBox(tbKolicina.text)没有到达

JavaScript脚本。无论我写入TextBox,我都会收到一个空的

警告框。但是,如果我以编程方式设置tbKolicina.text的值,

该值确实会被传递。因此我得出结论,只有最初的

值才能达到JavaScript。


我做错了什么,我怎样才能使这个验证工作?


提前谢谢你,

Hrvoje

解决方案



这应该将tbKolicina字段的值传递给函数

imgbtKosarica.Attributes.Add(" onclick"," return

validacija(this。 form.tbKolicina.value)")


-

最好的问候

Vidar Petursson

==============================

Microsoft Internet Client&控制MVP

==============================

" Hrvoje Vrbanc < HR ***** @ recro.hr>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

您好,

我有以下问题:
我的页面上有一个DataGrid控件,其中一列使用TextBox控件
,另一列使用ImageButton控件。为了在按下ImageButton时强制调用JavaScript客户端脚本,我将以下代码添加到OnItemDataBoundEvent(检查项目类型未显示
):

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是TextBox控件,当ImageButton调用imgbtKosarica时,我想将其值传递给
JavaScript进行验证单击。
JavaScript目前只是一个基本脚本(尚未验证),
应该只显示一个警告框,其中包含单击ImageButton时传递的参数
(tbKolicinaText)。 />
它工作正常(找到控件并调用JavaScript)最多一个
最后一点:TextBox(tbKolicina.text)的值没有达到
JavaScript脚本。无论我写入TextBox,我都会收到一个空的
警告框。但是,如果我以编程方式设置tbKolicina.text
的值,那么该值就会被传递。因此我得出结论,只有最初的
值才能达到JavaScript。

我做错了什么,我怎么能让这个验证工作?

提前谢谢你,
Hrvoje



Vidar,


感谢您的建议。

不幸的是,它仍然无法正常工作 - 它会在

警告框中显示错误消息:"''this.form.tbKolicina.value''为null或不为一个

对象....不知怎的,它不认识它。


Hrvoje

Vidar Petursson <第***** @ icysoft.com>在消息中写道

新闻:OY ************* @ TK2MSFTNGP10.phx.gbl ...



这应该将tbKolicina字段的值传递给函数
imgbtKosarica.Attributes.Add(" onclick"," return
validacija(this.form.tbKolicina.value)")

-
最诚挚的问候
Vidar Petursson
========================= =====
Microsoft Internet Client&控制MVP
==============================
" Hrvoje Vrbanc" < HR ***** @ recro.hr>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

你好,

我有以下问题:
我的页面上有一个DataGrid控件,带有TextBox控件的列


另一个带有ImageButton控件的控件。为了在按下ImageButton时强制调用JavaScript客户端脚本,我将以下代码添加到OnItemDataBoundEvent(检查项目类型未显示
):

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是TextBox控件,其值要传递给


JavaScript

,以便在ImageButton调用imgbtKosarica时进行验证。单击。
JavaScript目前只是一个基本脚本(尚未验证)
,只需显示一个警告框,其中包含单击ImageButton时传递的参数
(tbKolicinaText)。 />
它工作正常(找到控件并调用JavaScript)最多一个


final

point:TextBox的值(tbKolicina.text)没有达到
JavaScript脚本。无论我写入TextBox,我都会收到一个空的
警告框。但是,如果我以编程方式设置tbKolicina.text


的值,那么

该值确实会被传递。因此我得出结论,只有最初的
值才能达到JavaScript。

我做错了什么,我怎么能让这个验证工作?

提前谢谢你,
Hrvoje




您好


制作确保字段在那里,你的名字拼写正确(案例

敏感)


-

最好的问候

Vidar Petursson

==============================

Microsoft Internet Client&控制MVP

==============================

" Hrvoje Vrbanc < HR ***** @ recro.hr>在消息中写道

news:uN ************** @ TK2MSFTNGP10.phx.gbl ...

Vidar,
感谢您的建议。
不幸的是,它仍然无法正常工作 - 它会在
警告框中显示错误消息:"''this.form.tbKolicina.value' '是无效或不是对象'......不知怎的,它无法识别它。

Hrvoje

" Vidar Petursson" <第***** @ icysoft.com>在消息中写道
新闻:OY ************* @ TK2MSFTNGP10.phx.gbl ...



这个应该将tbKolicina字段的值传递给函数
imgbtKosarica.Attributes.Add(" onclick"," return
validacija(this.form.tbKolicina.value)")

-
最诚挚的问候
Vidar Petursson
============================= =
Microsoft Internet Client&控制MVP
==============================
" Hrvoje Vrbanc" < HR ***** @ recro.hr>在消息中写道
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

你好,

我有以下问题:
我的页面上有一个DataGrid控件,其中一列有TextBox
控件

和< blockquote class =post_quotes>另一个带有ImageButton控件。为了在按下ImageButton时强制调用JavaScript客户端脚本,我将以下代码添加到OnItemDataBoundEvent(检查项目类型未显示
):

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是TextBox控件,其值要传递给


JavaScript

,以便在ImageButton调用imgbtKosarica时进行验证。单击。
JavaScript目前只是一个基本脚本(尚未验证),只需显示一个警告框,其中包含单击ImageButton时传递的参数
(tbKolicinaText)。


final

点:TextBox(tbKolicina.text)的值不对到达
JavaScript脚本。无论我写入TextBox,我都会收到一个



空警报框。但是,如果我以编程方式设置tbKolicina.text


的值,那么

该值确实会被传递。因此我得出结论,只有
的初始值达到JavaScript。

我做错了什么,我怎么能让这个验证工作?

提前谢谢你,
Hrvoje





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

解决方案

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" <hr*****@recro.hr> wrote in message
news:%2****************@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,

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" <th*****@icysoft.com> wrote in message
news:OY*************@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" <hr*****@recro.hr> wrote in message
news:%2****************@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




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" <hr*****@recro.hr> wrote in message
news:uN**************@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" <th*****@icysoft.com> wrote in message
news:OY*************@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" <hr*****@recro.hr> wrote in message
news:%2****************@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





这篇关于从DataGrid OnItemDataBoundEvent调用的客户端脚本问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆