我在ASP.NET WebForms应用程序中使用ext.net
控件
它适用于Chrome 13-14,Opera 11,FF 6,但不适用于IE8
它会抛出JavaScript错误,例如:
无效的参数
和
BaseMainContent_MainContent_ctlContent_txtFax_txtCountryCode'未定义
如果有足够的信息,我该如何解决?
代码示例
<div>
<ext:TextField runat="server" MsgTarget="Side" ID="LoginTxt" IsRemoteValidation="true">
<RemoteValidation OnValidation="ValidateLogin" ShowBusy="true" />
</ext:TextField>
</div>
<br />
<div>
<div>
<ext:TextField ID="PasswordTxt1" runat="server" InputType="Password"></ext:TextField>
<ext:TextField runat="server" ID="PasswordTxt2" Vtype="password" FieldLabel="Повторите пароль"
InputType="Password" MsgTarget="Side" IsRemoteValidation="true">
<RemoteValidation OnValidation="ValidatePasswords" ShowBusy="true" />
</ext:TextField>
</div>
</div>
<div>
<ext:ComboBox Width="200" runat="server" ID="LocaleCmb" Editable="false"
SelectedIndex="0">
<Items>
<ext:ListItem Text="Русский" Value="ru-RU" />
<ext:ListItem Text="English" Value="en-US" />
</Items>
</ext:ComboBox>
</div>
<div>
<ext:TextField runat="server" ID="LastNameTxt" />
</div>
<ext:TextField runat="server" ID="EmailTxt" MsgTarget="Side" FieldLabel="Email" Vtype="email"
IsRemoteValidation="true">
<RemoteValidation OnValidation="ValidateEmail" ShowBusy="true" />
</ext:TextField>
<div>
<uc:PhoneTextBox2 ID="PhoneUc" runat="server"/>
</div>
<div>
<uc:PhoneTextBox2 ID="FaxUc" runat="server" />
</div>
<br />
<div>
<uc:Address2 Title="Адрес" ID="AddressUc" CoordinatesVisible="false" runat="server" />
</div>
<div>
<div id="RecaptchaDiv" runat="server" class="x-form-invalid-icon" style="left: 350px; top: 0px;
position: relative; visibility: visible;">
</div>
<recaptcha:RecaptchaControl ID="Recaptcha" runat="server" />
</div>
<ext:Button runat="server" ID="SubmitTxt" Text="Register me">
<DirectEvents>
<Click OnEvent="SubmitBtnClick">
<EventMask ShowMask="true"></EventMask>
</Click>
</DirectEvents>
</ext:Button>
<uc:BackLinkButton ID="lnkPreviousPage" runat="server" />
在这种情况下,错误是
SCRIPT87: Invalid argument.
ext.axd?v=21945, line 7 character 31283
更新: 截图
UPDATE2: 我忘了说我在IE9中工作得很好。 这是uc的源代码:PhoneTextBox2
<style>
.invalidPhoneBox
{
border-color: #C30;
background: url('/extjs/resources/images/default/grid/invalid_line-gif/ext.axd') repeat-x scroll center bottom white;
}
</style>
<ext:CompositeField runat="server" ID="eCompositeField" CombineErrors="false" AutoWidth="true"
MsgTarget="Title">
<Items>
<ext:DisplayField runat="server" Text="(" />
<ext:NumberField ID="txtCountryCode" Width="29" AllowNegative="false" AllowDecimals="false"
MaxLength="3" runat="server" />
<ext:DisplayField runat="server" Text=")" />
<ext:NumberField runat="server" ID="txtCityCode" Width="58" AllowNegative="false" AllowDecimals="false"
MaxLength="7" />
<ext:TextField runat="server" ID="txtMainPhoneNumber" Width="60" MaxLength="7" AllowNegative="false"
AllowDecimals="false" />
<ext:TextField runat="server" ID="txtExtraPhoneNumber" Width="44" AllowBlank="false" MaxLength="5"
AllowNegative="false" AllowDecimals="false" MsgTarget="Side" />
</Items>
</ext:CompositeField>
背后的代码
public partial class PhoneTextBox2 : System.Web.UI.UserControl {
public bool EnableEmptyValues { get; set; }
public string Title { get; set; }
protected void Page_Init(object sender, EventArgs e) {
txtCountryCode.AllowBlank = EnableEmptyValues;
txtCityCode.AllowBlank = EnableEmptyValues;
txtMainPhoneNumber.AllowBlank = EnableEmptyValues;
}
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
eCompositeField.FieldLabel = Title;
// eCompositeField.LabelWidth = Title.Length*5;
if (!string.IsNullOrWhiteSpace(DataSource)) {
string[] phoneNumberArray = DataSource.Split('-');
if (phoneNumberArray.Length >= _standartDimension) {
txtCountryCode.Text = phoneNumberArray[0];
if (txtCountryCode.Text[0] == _plus) {
txtCountryCode.Text = txtCountryCode.Text.Remove(0, 1);
}
txtCityCode.Text = phoneNumberArray[1];
txtMainPhoneNumber.Text = phoneNumberArray[2];
if (phoneNumberArray.Length >= _extraDimension) {
txtExtraPhoneNumber.Text = phoneNumberArray[3];
}
}
}
}
}
public string DataSource { get; set; }
private const string _phoneNumberMask = "+{0}-{1}-{2}-{3}";
private const char _plus = '+';
private const int _standartDimension = 3;
private const int _extraDimension = 4;
public string Number {
get {
if (!string.IsNullOrWhiteSpace(txtCountryCode.Text) &&
!string.IsNullOrWhiteSpace(txtCityCode.Text) &&
!string.IsNullOrWhiteSpace(txtMainPhoneNumber.Text)) {
if (!string.IsNullOrWhiteSpace(txtExtraPhoneNumber.Text))
return string.Format(_phoneNumberMask, txtCountryCode.Text, txtCityCode.Text, txtMainPhoneNumber.Text, txtExtraPhoneNumber.Text);
string phoneNumber = string.Format(_phoneNumberMask, txtCountryCode.Text, txtCityCode.Text, txtMainPhoneNumber.Text, string.Empty);
return phoneNumber.Remove(phoneNumber.Length - 1);
}
return string.Empty;
}
}
public bool IsEmpty {
get {
return (string.IsNullOrWhiteSpace(txtCountryCode.Text) &&
string.IsNullOrWhiteSpace(txtCityCode.Text) &&
string.IsNullOrWhiteSpace(txtMainPhoneNumber.Text) &&
string.IsNullOrWhiteSpace(txtMainPhoneNumber.Text));
}
}
/// <summary>
/// Validate
/// </summary>
public void Validate() {
if (EnableEmptyValues) {
if (!IsEmpty && Number == string.Empty)
MarkInvalid();
else
MarkValid();
}
else {
if (IsEmpty)
MarkInvalid();
else {
if (Number == string.Empty)
MarkInvalid();
else
MarkValid();
}
}
}
private const string InvalidFormatNumberMessage = "InvalidFormatNumberMessage";
private const string EmptyNumberMessage = "EmptyNumberMessage";
private const string InvalidCls = "invalidPhoneBox";
public void MarkInvalid(string msg = null) {
// eCompositeField.AddLabelCls(InvalidCls);
txtCountryCode.MarkInvalid(msg);
txtCityCode.MarkInvalid(msg);
txtMainPhoneNumber.MarkInvalid(msg);
txtExtraPhoneNumber.MarkInvalid(msg);
}
public void MarkValid() {
//eCompositeField.RemoveLabelCls(InvalidCls);
//eCompositeField.MarkAsValid();
txtCountryCode.MarkAsValid();
txtCityCode.MarkAsValid();
txtMainPhoneNumber.MarkAsValid();
txtExtraPhoneNumber.MarkAsValid();
}
public const string InvalidCheckBoxCssStyle = "border-color:#C30; background: url('/extjs/resources/images/default/grid/invalid_line-gif/ext.axd') repeat-x scroll center bottom white; width: 40px !important;";
public const string ValidCheckBoxCssStyle = "border-color:#000; background: none repeat scroll 0 0 transparent;";
}
答案 0 :(得分:0)
我有这个确切的错误,虽然我不能完全重现你的情况,但我希望能给你一个如何解决它的好主意。问题是,无效的宽度被分配给页面上的一个控件。这可能是因为标记中的某些不正确的配置,或者可能是Ext.NET中的某种错误。要确定哪个控件出错:
希望这些步骤可以帮助您缩小导致错误的控制并纠正错误。在我的情况下,我使用了AutoWidth =“True”。更改为AnchorHorizontal =“100%”解决了问题。