Sys.InvalidOperationException: The id property can't be set on this object.

visibility 320 access_time 14 years ago language中文 timeline Stats
timeline Stats
Page index 0.06
Sys.InvalidOperationException: The id property can't be set on this object.
$create(Juice.SysUI.Prompt, {"content":"","height":{"IsEmpty":true,"Type":1,"Value":0},"id":"juiceprompt","onCancelBtnID":"","onCancelScript":"","onCloseRefresh":true,"onCloseScript":"","onOKBtnID":"","onOKScript":"","title":"测试","width":{"IsEmpty":true,"Type":1,"Value":0}}, null, null, $get("ctl00_adminContentPlaceHolder_prompt1"));
百度了下没有找到任何解决方案 于是 google了下 看到确实有很多人遇到了这个问题最终在这里找到了问题的解决方法

这篇文章中有个人说的方法确实可以解决 因为我的Juice.SysUIPrompt确实是继承自Sys.UI.Control的 如果改成Behavior的话就不会出现这个错误的


Thank you for your post!

I think it is normal!

Here is the reason:

We cann't change the ID property of a Dom object at client side via javascript, the Id cann't be changed after the DOM object is explained by browser.

The following code is supposed to change the ID property of a DOM object which is not allowed. so the error fired.

$create(Demo.HoverButton, {id:'testId',text: 'A HoverButton Control',element: {style: {fontWeight: "bold", borderWidth: "2px"}}}, {click: start, hover: doSomethingOnHover, unhover: doSomethingOnUnHover},null, $get('Button1'));

Sys.UI.Behavior works fine beause Behavior don't render as DOM objects, they are rendered as plain javascript objects.

If you have further questions,let me know!

Best Regards,


可是文档里边偏偏说的是可以设置id属性的 因为本来Control和Behavior都是继承自Sys.Component的嘛

再继续看下去哈哈官方团队给了解释 是文档除了错,唉浪费了我这么多时间

It's the documentation that's wrong here. The id can't be set on a control. The id of a control is the id of the element it's attached to. I'll make sure the documentation is updated.

Thanks for the feedback.

This posting is provided "AS IS" with no warranties, and confers no rights.

P.S.:查询代码这些 Google比百度还是强多了
info Last modified by Raymond 14 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Table of contents