服务器标记的格式不正确。当参数传递到javascript函数 [英] The server tag is not well formed. When passing parameters to javascript function

查看:136
本文介绍了服务器标记的格式不正确。当参数传递到javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜始终与调用带参数的值JavaScript函数保税到GridView值的麻烦。我按照 SO线程但是不能用于传递这个参数。下面是我在aspx页面中使用的语句。

Hi have always trouble with calling JavaScript function with parameters values as values bonded to the gridview. I follow SO Thread But can not used for passing this parameter . Below is the statement that I used in my aspx page.

onblur="return ValidateText(this,'<%# Eval("vehicleId") %>')"

但是,这给了我服务器标记的格式不正确解析错误。我应该如何(后面没有code)要求在设计这个功能只。

But this gives me parsing error The server tag is not well formed. How should I call this function in design only(not from code behind).

推荐答案

这个工作,但因为我去掉了封闭的报价似乎是HACK(抗XHTML)

This works, but seems an HACK because I removed the enclosing quotes (anti-XHtml)

 onblur=<%# String.Format("return ValidateText(this, '{0}')", Eval("VehicleID")) %>

问题是有''''作为字符串的一部分。

The problem is having " "" " or ' '' ' as part of the string.

这是做得更好(我希望它是更容易的标记),在code-后面,例如的RowDataBound或的ItemDataBound

This is better done (I wish it is easier in markup), in code-behind, e.g. RowDataBound or ItemDataBound

 control.Attributes["onblur"] = String.Format("return ValidateText(this, '{0}')", rowValue);

这篇关于服务器标记的格式不正确。当参数传递到javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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