userName = Global.getComponent('centerRegion').UserName.getValue();
值該代碼會彈出錯誤的Javascript不拉從形式
{"browserEvent":"'Global.getComponent(...).UserName' is null or not an object","button":-1,"ctrlKey":false,"xy":[0,0]}
當我這個表上運行它:
Using Form As New WebControls.Forms.Form
With Form
.ID = "Test"
.ItemName = "connector"
With .Toolbar
.UseDefaultButtons = False
.AddButton(Forms.FormToolbar.ButtonType.Save)
.AddButton(Forms.FormToolbar.ButtonType.Cancel)
.AddButton("Test Connection", "testConnection", "icon-button-testconnection", , "Test")
End With
With .CenterRegion
.Id = "centerRegion"
With .AddFieldSet("Activate Service")
.Id = "activate"
.LabelWidth = 0
Dim cb As New Forms.Control("IsActive", "", "", Model.IsActive, Forms.Control.ControlType.CheckBox)
cb.BoxLabel = "Activate Service"
.AddControl(cb)
End With
With .AddFieldSet("Connection Parameters")
.Id = "params"
.LabelWidth = 150
.AddControl(New Forms.Control("UserName", "", "User Name", Model.UserName, Forms.Control.ControlType.TextField))
.AddControl(New Forms.Control("Password", "", "Password", Model.Password, Forms.Control.ControlType.Password))
.AddControl(New Forms.Control("LoginUrl", "", "URL", Model.LoginUrl))
End With
End With
Response.Write(.ToString)
End With
End Using
一切都顯示出來,並從形式正確保存在屏幕上,所以值是那裏,但我認爲我的JavaScript是錯誤的拉它。
編輯:
生成的HTML:
xtype:'fieldset'
,title:'Connection Parameters'
,id:'params',autoHeight:true
,titleCollapse:true
,border:true
,collapsible:false
,labelWidth:139
,anchor:'100%'
,items:[
{xtype:'textfield',validationEvent:'blur',enableKeyEvents:true,anchor:'100%',value:'IDWSSample',fieldLabel:'User Name',itemId:'UserName',name:'UserName',allowDecimals:false,decimalPrecision:0,validator:function(value){var isCustomValid = true;if (this.ux_isInitialized == true) {isCustomValid = function(value){if (value.match(/<[a-zA-Z!\/]{1}/)) return 'If using the "<" character, it must not be followed by "!" or "/" or any letter.';if (value.match(/.*&#.*/)) return 'If using the "&" character, it must not be followed by "#".';return true;}(value);if (typeof(isCustomValid) == 'string') return isCustomValid;}if (isCustomValid == null) isCustomValid = true;return isCustomValid;}}
,
{xtype:'textfield',validationEvent:'blur',enableKeyEvents:true,anchor:'100%',value:'TcYg7m*a',fieldLabel:'Password',itemId:'Password',name:'Password',allowDecimals:false,decimalPrecision:0,inputType:'password'
}
,
{xtype:'textfield',validationEvent:'blur',enableKeyEvents:true,anchor:'100%',value:'http://sample.idws.syndication.kbb.com/VehicleInformationService2008R2.svc?wsdl',fieldLabel:'URL',itemId:'LoginUrl',name:'LoginUrl',allowDecimals:false,decimalPrecision:0,validator:function(value){var isCustomValid = true;if (this.ux_isInitialized == true) {isCustomValid = function(value){if (value.match(/<[a-zA-Z!\/]{1}/)) return 'If using the "<" character, it must not be followed by "!" or "/" or any letter.';if (value.match(/.*&#.*/)) return 'If using the "&" character, it must not be followed by "#".';return true;}(value);if (typeof(isCustomValid) == 'string') return isCustomValid;}if (isCustomValid == null) isCustomValid = true;return isCustomValid;}}
,
{xtype:'combo_transform',validationEvent:'blur',enableKeyEvents:true,anchor:'100%',fieldLabel:'Market Value',id:'ddlMarketValues',itemId:'ddlMarketValues',name:'ddlMarketValues',allowDecimals:false,decimalPrecision:0,id:'EXT_ddlMarketValues'
,el:null
,typeAhead:true
,triggerAction:'all'
,transform:'ddlMarketValues'
,forceSelection:true
,selectOnFocus:true
,lazyRender:true
,resizable:true
,editable:false
當我嘗試$ find時,它說$ find沒有被定義。當我嘗試第一個建議時,出現此錯誤「document.getElementById(」UserName「)爲null」 – Scott 2010-09-02 14:18:31
請確保在aspx頁面中有一個ScriptManager對象,以便您可以使用$ find。 null從document.getElementById表示「UserName」不是實際的id值。這可能類似於「ctl00_UserName」。您可以通過將控件的ClientID值注入服務器端代碼的頁面腳本中來訪問它。 – Silkster 2010-09-02 14:35:03
仍然沒有能夠得到這個工作。有任何想法嗎? – Scott 2010-09-02 16:26:41