PDA

View Full Version : [CLOSED] id not found in base class.



hdsoso
Aug 18, 2014, 4:28 PM
hi ext.net team

I want to create a LoginPage class which pop a window for logining , when a page extend the LoginPage , the page will have the login ability.
but when click the "fresh" and " login " button , show the error:
The control with ID 'btn_refresh' not found
The control with ID 'btn_submit' not found

though i have set IDMODE = static , but not work , please help me . thanks.

aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="info.hdsoso.com.test.WebForm3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
base.CreateLoginWindow();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" SourceFormatting="True"></ext:ResourceManager>
</form>
</body>
</html>


aspx's code behind


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using webbase.qizweb.com;

namespace info.hdsoso.com.test
{
public partial class WebForm3 : LoginPage
{

}
}

LoginPage:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ext.Net;
using service.qizweb.com;

namespace webbase.qizweb.com
{
public class LoginPage : System.Web.UI.Page
{
// readonly UserService _userService = new UserService();
protected void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,
IDMode = IDMode.Static
};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),
ID = "fp_1"
};
var btnreset = new Ext.Net.Button { Text = "取消", ID = "btn_reset", IDMode = IDMode.Static };
btnreset.Listeners.Click.Handler = "#{fp_1}.reset();";
var btnsubmit = new Ext.Net.Button { Text = "登录", ID = "btn_submit", IDMode = IDMode.Static };
btnsubmit.DirectEvents.Click.Event += Login;
fp.Buttons.Add(btnreset);
fp.Buttons.Add(btnsubmit);
var tfName = new TextField
{
ID = "tf_uname",
FieldLabel = "用户名",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70
};
var tfPass = new TextField
{
ID = "tf_pass",
FieldLabel = "密码",
AnchorHorizontal = "100%",
InputType = InputType.Password,
Margin = 4,
LabelWidth = 70
};
fp.Items.Add(tfName);
fp.Items.Add(tfPass);
var fc = new FieldContainer
{
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
FieldLabel = "验证码"
};
fc.LayoutConfig.Add(new HBoxLayoutConfig { Align = HBoxAlign.Middle });
var rand = new Random().Next(100000, 999999).ToString();
var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true
};

fc.Items.Add(dfYzm);
fc.Items.Add(new Component { Flex = 1 });
var btnfresh = new Ext.Net.Button { ID = "btn_refresh", Text = "刷新",IDMode = IDMode.Static };
btnfresh.DirectEvents.Click.Event += NewYzm;
fc.Items.Add(btnfresh);
fp.Items.Add(fc);
fp.Items.Add(new TextField
{
FieldLabel = "输入验证码",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
ID = "tf_yzm1"
});
var notlogin = new FieldContainer()
{
FieldLabel = "登录不上?",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70

};
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_reg.aspx",
Text = "注册",
Margin = 4
});
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_index.aspx",
Text = "返回首页",
Margin = 4
});
fp.Items.Add(
notlogin
);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void NewYzm1()
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void Login(object sender, DirectEventArgs e)
{
var uname = Request["tf_uname"];

var pass = Request["tf_pass"];
var yzm = Request["tf_yzm"];
var yzm1 = Request["tf_yzm1"];

if (yzm == yzm1)
{
// if (_userService.Login(uname, pass))
// {
// var u = _userService.GetUserByName(uname);
// _userService.WriteSessionAndCookie(u);
Response.Redirect("~/fenlei_user.aspx");
// }
// else
// {
// X.MessageBox.Alert("提示", "登陆失败").Show();
// NewYzm1();

// }
}
else
{
X.MessageBox.Alert("提示", "验证码不正确").Show();
NewYzm1();
}


}


}
}

Daniil
Aug 18, 2014, 4:39 PM
Hi @hdsoso,

I guess I've explained that here.
http://forums.ext.net/showthread.php?41801

Please remove

if (!IsPostBack)
if you need DirectEvents working.

hdsoso
Aug 18, 2014, 5:31 PM
thank you ,
in my project , I use FenleiUser to extend the LoginPage ,
show error below
14571
loginpage:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ext.Net;
using service.qizweb.com;

namespace webbase.qizweb.com
{
public class LoginPage : System.Web.UI.Page
{
readonly UserService _userService = new UserService();
protected void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,
IDMode = IDMode.Static
};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),
ID = "fp_1"
};
var btnreset = new Ext.Net.Button { Text = "取消", ID = "btn_reset", IDMode = IDMode.Static };
btnreset.Listeners.Click.Handler = "#{fp_1}.reset();";
var btnsubmit = new Ext.Net.Button { Text = "登录", ID = "btn_submit", IDMode = IDMode.Static };
btnsubmit.DirectEvents.Click.Event += Login;
fp.Buttons.Add(btnreset);
fp.Buttons.Add(btnsubmit);
var tfName = new TextField
{
ID = "tf_uname",
FieldLabel = "用户名",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70
};
var tfPass = new TextField
{
ID = "tf_pass",
FieldLabel = "密码",
AnchorHorizontal = "100%",
InputType = InputType.Password,
Margin = 4,
LabelWidth = 70
};
fp.Items.Add(tfName);
fp.Items.Add(tfPass);
var fc = new FieldContainer
{
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
FieldLabel = "验证码"
};
fc.LayoutConfig.Add(new HBoxLayoutConfig { Align = HBoxAlign.Middle });
var rand = new Random().Next(100000, 999999).ToString();
var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true
};

fc.Items.Add(dfYzm);
fc.Items.Add(new Component { Flex = 1 });
var btnfresh = new Ext.Net.Button { ID = "btn_refresh", Text = "刷新", IDMode = IDMode.Static };
btnfresh.DirectEvents.Click.Event += NewYzm;
fc.Items.Add(btnfresh);
fp.Items.Add(fc);
fp.Items.Add(new TextField
{
FieldLabel = "输入验证码",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
ID = "tf_yzm1"
});
var notlogin = new FieldContainer()
{
FieldLabel = "登录不上?",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70

};
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_reg.aspx",
Text = "注册",
Margin = 4
});
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_index.aspx",
Text = "返回首页",
Margin = 4
});
fp.Items.Add(
notlogin
);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void NewYzm1()
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void Login(object sender, DirectEventArgs e)
{
var uname = Request["tf_uname"];

var pass = Request["tf_pass"];
var yzm = Request["tf_yzm"];
var yzm11 = Request["tf_yzm11"];

if (yzm == yzm11)
{
if (_userService.Login(uname, pass))
{
var u = _userService.GetUserByName(uname);
_userService.WriteSessionAndCookie(u);
Response.Redirect("~/fenlei_user.aspx");
}
else
{
X.MessageBox.Alert("提示", "登陆失败").Show();
NewYzm1();
}
}
else
{
X.MessageBox.Alert("提示", "验证码不正确").Show();
NewYzm1();
}
}
}
}


fenleiuser:


<%@ Page Title="" Language="C#" MasterPageFile="~/fenlei.Master" AutoEventWireup="true" CodeBehind="fenlei_user.aspx.cs" Inherits="info.hdsoso.com.FenleiUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<title>用户中心-奇卓网络</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<script type="text/javascript">
var renderTitle1 = function (value, metadata, record, rowIndex, colIndex, store, view) {
var link = "<a target='_blank' href='fenlei_item.aspx?id=" + record.data.id + "&prov=" + record.data.provid + "&city=" + record.data.cityid + "'>" + value + "</a>";
return link;
};

</script>
<style>
.x-form-radio:hover {
cursor: pointer;
}
</style>
<div id="content">
<h1>欢迎您!<ext:Label runat="server" ID="l_user"></ext:Label>
</h1>
<div class="welcome">

<ext:TabPanel runat="server" Frame="true" ID="TabPanel1">
<Items>
<ext:FormPanel runat="server" Title="信息发布" ID="form_user">
<Items>
<ext:FieldSet runat="server" Title="选择省份" Margin="4">
<Items>
<ext:RadioGroup runat="server" ID="rg_prov" Layout="ColumnLayout" IDMode="Static">
</ext:RadioGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="选择城市" Margin="4">
<Items>
<ext:RadioGroup runat="server" Layout="ColumnLayout" ID="rg_city" IDMode="Static">
</ext:RadioGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="选择类别" Margin="4">
<Items>
<ext:RadioGroup runat="server" Layout="ColumnLayout" ID="rg_type" IDMode="Static">
</ext:RadioGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="选择子类别" Margin="4">
<Items>
<ext:RadioGroup runat="server" Layout="ColumnLayout" ID="rg_type1" IDMode="Static">
</ext:RadioGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="选择详细类别" Margin="4">
<Items>
<ext:RadioGroup runat="server" Layout="ColumnLayout" ID="rg_type2" IDMode="Static">
</ext:RadioGroup>
</Items>
</ext:FieldSet>
<ext:FieldSet runat="server" Title="填写内容" Margin="4">
<Items>
<ext:TextField runat="server" LabelWidth="70" InputWidth="840" FieldLabel="标题" ID="tf_title"></ext:TextField>
<ext:HtmlEditor runat="server" LabelWidth="70" MinHeight="350" FieldLabel="内容" ID="he_cont"></ext:HtmlEditor>
<ext:TextField runat="server" LabelWidth="70" InputWidth="840" FieldLabel="联系电话" ID="tf_tel"></ext:TextField>
<ext:FieldContainer runat="server" LabelWidth="70" FieldLabel="验证码" Layout="HBoxLayout">
<Items>
<ext:TextField runat="server" ReadOnly="True" ID="tf_valid_new"></ext:TextField>
<ext:Button runat="server" Text="刷新" ID="b_fresh">
<DirectEvents>
<Click OnEvent="ChangeValid"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:FieldContainer>
<ext:TextField runat="server" ID="tf_yzm1" LabelWidth="70" FieldLabel="确认验证码"></ext:TextField>
</Items>
</ext:FieldSet>
</Items>
<Buttons>
<ext:Button runat="server" Text="取消" Icon="Cancel">
<Listeners>
<Click Handler="
#{form_user}.reset();
">
</Click>
</Listeners>
</ext:Button>
<ext:Button ID="Button1" runat="server" Text="提交" Icon="Add">
<DirectEvents>
<Click OnEvent="AddInfo"></Click>
</DirectEvents>
</ext:Button>
</Buttons>
</ext:FormPanel>
<ext:GridPanel runat="server" Title="我的信息">
<Store>
<ext:Store runat="server" ID="s_info" OnReadData="LoadUserPost">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="id"></ext:ModelField>
<ext:ModelField Name="title"></ext:ModelField>
<ext:ModelField Name="catename"></ext:ModelField>
<ext:ModelField Name="postuser"></ext:ModelField>
<ext:ModelField Name="city"></ext:ModelField>
<ext:ModelField Name="addtime"></ext:ModelField>
<ext:ModelField Name="cityid"></ext:ModelField>
<ext:ModelField Name="provid"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy></ext:PageProxy>
</Proxy>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="id" Text="编号"></ext:Column>
<ext:Column runat="server" DataIndex="title" Text="标题" Flex="1">
<Renderer Fn="renderTitle1">
</Renderer>
</ext:Column>
<ext:Column runat="server" DataIndex="catename" Text="类别"></ext:Column>
<ext:Column runat="server" DataIndex="city" Text="城市"></ext:Column>
<ext:Column runat="server" DataIndex="postuser" Text="发布人"></ext:Column>
<ext:DateColumn runat="server" DataIndex="addtime" Format="yyyy-MM-dd" Text="发布时间"></ext:DateColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
</Items>
<Listeners>
<TabChange Handler="
if(this.activeTab.title=='我的信息'){
#{s_info}.reload();
}
">
</TabChange>
</Listeners>
</ext:TabPanel>



</div>
</div>
</asp:Content>




using System;
using System.Linq;
using dao.qizweb.com;
using Ext.Net;
using model.qizweb.com;
using service.qizweb.com;
using tools.qizweb.com;
using webbase.qizweb.com;

namespace info.hdsoso.com
{
public partial class FenleiUser : LoginPage
{
readonly ProvinDao _provinDao = new ProvinDao();
readonly CityDao _cityDao = new CityDao();
readonly InfoCateDao _infoCateDao = new InfoCateDao();
readonly InfoDao _infoDao = new InfoDao();
readonly UserService _userService = new UserService();
protected void Page_Load(object sender, EventArgs e)
{
// if (Session["user"] == null)
if (!_userService.IsLogin())
{
base.CreateLoginWindow();
}
else
{
var u = _userService.GetUserFromSeesionOrCookie();
l_user.Text = u.uname;

}
LoadProv();
rg_prov.DirectEvents.Change.Event += ChangeProv;

LoadInfoType();
rg_type.DirectEvents.Change.Event += ChangeProv1;
rg_type1.DirectEvents.Change.Event += ChangeProv2;

if (!X.IsAjaxRequest)
{
var valinum = new Random().Next(100000, 999999).ToString();
tf_valid_new.Text = valinum;
}

}
protected void ChangeValid(object sender, DirectEventArgs e)
{
var valinum = new Random().Next(100000, 999999).ToString();
tf_valid_new.Text = valinum;
}



private void LoadProv()
{
rg_prov.Items.Clear();
var prolist = _provinDao.AllProDto();
foreach (var proDto in prolist)
{
rg_prov.Items.Add(new Radio { FieldLabel = proDto.Provincial, LabelAlign = LabelAlign.Right, InputValue = proDto.Pid.ToString(), CssClass = "hoverme" });
}
}
private void LoadInfoType()
{
rg_type.Items.Clear();
var prolist = _infoCateDao.InfoCatesByPid(-1);
foreach (var proDto in prolist)
{
rg_type.Items.Add(new Radio { FieldLabel = proDto.cate, LabelAlign = LabelAlign.Right, InputValue = proDto.id.ToString() });
}
}

private void ChangeProv(object sender, DirectEventArgs e)
{

var pid = this.Request["App.rg_prov_Group"];
rg_city.Items.Clear();
var cities = _cityDao.CitiesByProv(Convert.ToInt32(pid));
var cityradio = cities.Select(v => new Radio { FieldLabel = v.city, InputValue = v.id.ToString(), LabelAlign = LabelAlign.Right }).ToList();
rg_city.Items.AddRange(cityradio);
rg_city.ReRender();
}
private void ChangeProv1(object sender, DirectEventArgs e)
{
var pid = this.Request["App.rg_type_Group"];
rg_type1.Items.Clear();
var cities = _infoCateDao.InfoCatesByPid(Convert.ToInt32(pid));
var cityradio = cities.Select(v => new Radio { FieldLabel = v.cate, InputValue = v.id.ToString(), LabelAlign = LabelAlign.Right }).ToList();

rg_type1.Items.AddRange(cityradio);
rg_type1.ReRender();

}
private void ChangeProv2(object sender, DirectEventArgs e)
{
var pid = this.Request["App.rg_type1_Group"]; //
rg_type2.Items.Clear();
var cities = _infoCateDao.InfoCatesByPid(Convert.ToInt32(pid));
var cityradio = cities.Select(v => new Radio { FieldLabel = v.cate, InputValue = v.id.ToString(), LabelAlign = LabelAlign.Right }).ToList();
rg_type2.Items.AddRange(cityradio);
rg_type2.ReRender();

}

protected void LoadUserPost(object sender, StoreReadDataEventArgs e)
{
var start = e.Start;
var limit = e.Limit;
var u = _userService.GetUserFromSeesionOrCookie();
if (u != null)
{
int total;
var infos = _infoDao.InfoList(start, limit, out total, u);
var infos1 = infos.Select(v => new
{
id = v.id,
title = v.title,
catename = v.QizInfoCate.cate,
postuser = v.QizUser.uname,
city = v.QizCity.city,
addtime = v.addtime,
cityid = v.cityid,
provid = v.QizCity.QizProvincial.pid
});
e.Total = total;
s_info.DataSource = infos1;
s_info.DataBind();
}

}
protected void AddInfo(object sender, DirectEventArgs e)
{
var input = tf_yzm1.Text;
var validinput = tf_valid_new.Text;
// bool b = CaptchaImage1.TestText(input);
if (input != validinput)
{
X.Msg.Alert("提示", "验证码不正确").Show();
return;
}
var city = this.Request["App.rg_city_Group"];
var infotype = this.Request["App.rg_type2_Group"];
var title = tf_title.Text;
var cont = he_cont.Text;
// var u = (QizUser)Session["user"];
var u = _userService.GetUserFromSeesionOrCookie();
try
{
var o = new QizInfo
{
title = title,
info = cont,
cateid = Convert.ToInt32(infotype),
cityid = Convert.ToInt32(city),
userid = u.id,
addtime = DateTime.Now,
tel = tf_tel.Text
};
_infoDao.Add(o);
X.Msg.Alert("提示", "信息发布成功").Show();
tf_title.Text = "";
he_cont.Text = "";

}
catch (Exception ee)
{
X.Msg.Alert("提示", ee.InnerException).Show();
}

}
}
}

in sample code , works fine. but , in real project , show error:
Uncaught TypeError: Cannot call method 'setValue' of undefined

is there something wrong?

Daniil
Aug 19, 2014, 2:21 PM
Maybe, you pass a wrong ID into one of X.GetCmp calls. If you use a MasterPage, client ids of controls don't equal its server IDs. It will be "ContentPlaceHolderID_ControlID" by default. It is something that you should pass to X.GetCmp.

Another approach is to force client ids to be the same as server IDs by setting IDMode="Static" for a control.

hdsoso
Aug 19, 2014, 4:44 PM
i try to set idmode = static , but the textfeld's id is "tf_yzm-inputEl" from html source .
below is my test case which using mater page .
loginpage:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ext.Net;
using service.qizweb.com;

namespace webbase.qizweb.com
{
public class LoginPage : System.Web.UI.Page
{
readonly UserService _userService = new UserService();
protected void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,
IDMode = IDMode.Static
};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),
ID = "fp_1"
};
var btnreset = new Ext.Net.Button { Text = "取消", ID = "btn_reset", IDMode = IDMode.Static };
btnreset.Listeners.Click.Handler = "#{fp_1}.reset();";
var btnsubmit = new Ext.Net.Button { Text = "登录", ID = "btn_submit", IDMode = IDMode.Static };
btnsubmit.DirectEvents.Click.Event += Login;
fp.Buttons.Add(btnreset);
fp.Buttons.Add(btnsubmit);
var tfName = new TextField
{
ID = "tf_uname",
FieldLabel = "用户名",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70
};
var tfPass = new TextField
{
ID = "tf_pass",
FieldLabel = "密码",
AnchorHorizontal = "100%",
InputType = InputType.Password,
Margin = 4,
LabelWidth = 70
};
fp.Items.Add(tfName);
fp.Items.Add(tfPass);
var fc = new FieldContainer
{
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
FieldLabel = "验证码"
};
fc.LayoutConfig.Add(new HBoxLayoutConfig { Align = HBoxAlign.Middle });
var rand = new Random().Next(100000, 999999).ToString();
var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true,
IDMode = IDMode.Static
};

fc.Items.Add(dfYzm);
fc.Items.Add(new Component { Flex = 1 });
var btnfresh = new Ext.Net.Button { ID = "btn_refresh", Text = "刷新", IDMode = IDMode.Static };
btnfresh.DirectEvents.Click.Event += NewYzm;
fc.Items.Add(btnfresh);
fp.Items.Add(fc);
fp.Items.Add(new TextField
{
FieldLabel = "输入验证码",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
ID = "tf_yzm1"
});
var notlogin = new FieldContainer()
{
FieldLabel = "登录不上?",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70

};
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_reg.aspx",
Text = "注册",
Margin = 4
});
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_index.aspx",
Text = "返回首页",
Margin = 4
});
fp.Items.Add(
notlogin
);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void NewYzm1()
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void Login(object sender, DirectEventArgs e)
{
var uname = Request["tf_uname"];

var pass = Request["tf_pass"];
var yzm = Request["tf_yzm"];
var yzm11 = Request["tf_yzm11"];

if (yzm == yzm11)
{
if (_userService.Login(uname, pass))
{
var u = _userService.GetUserByName(uname);
_userService.WriteSessionAndCookie(u);
Response.Redirect("~/fenlei_user.aspx");
}
else
{
X.MessageBox.Alert("提示", "登陆失败").Show();
NewYzm1();
}
}
else
{
X.MessageBox.Alert("提示", "验证码不正确").Show();
NewYzm1();
}
}
}
}



site1.master


<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="info.hdsoso.com.test.Site1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" SourceFormatting="True" />
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>


webform4's front code


<%@ Page Title="" Language="C#" MasterPageFile="~/test/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="info.hdsoso.com.test.WebForm4" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>


webform4 's behind code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using webbase.qizweb.com;

namespace info.hdsoso.com.test
{
public partial class WebForm4 : LoginPage
{
protected void Page_Load(object sender, EventArgs e)
{
base.CreateLoginWindow();
}
}
}

Daniil
Aug 20, 2014, 5:38 AM
i try to set idmode = static , but the textfeld's id is "tf_yzm-inputEl" from html source .

Yes, an id of a TextField component and its underlying <input> HTML element are not the same. To a .X.GetCmp<>() call you should pass a client id of the TextField component which is "tf_yzm".

hdsoso
Aug 20, 2014, 7:01 AM
but , i have set idmode=static


var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true,
IDMode = IDMode.Static
};

and


private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}

in my last demo which use master page. also show the error:
can not call method "setValue" of undefined.

Daniil
Aug 20, 2014, 8:29 AM
Ok, we should determine what is "undefined" here:

can not call method "setValue" of undefined.

It looks like

something.setValue(...)

What is something?

hdsoso
Aug 20, 2014, 9:00 AM
the error shown in ext.net , could you please test in my last demo?

Daniil
Aug 20, 2014, 12:45 PM
I think your code will throw an Exception for me.

Is there any chance you could answer my question?

hdsoso
Aug 22, 2014, 1:53 PM
i do not know why it throw the error
Uncaught TypeError: Cannot call method 'setValue' of undefined
please review my test case below.
master page:


<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="info.hdsoso.com.test.Site1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" SourceFormatting="True" />
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>


webform4:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using webbase.qizweb.com;

namespace info.hdsoso.com.test
{
public partial class WebForm4 : LoginPage1
{
protected void Page_Load(object sender, EventArgs e)
{
base.CreateLoginWindow();
}
}
}

webform4:


<%@ Page Title="" Language="C#" MasterPageFile="~/test/Site1.Master" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="info.hdsoso.com.test.WebForm4" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>


loginpage1:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ext.Net;
using service.qizweb.com;

namespace webbase.qizweb.com
{
public class LoginPage1 : System.Web.UI.Page
{
//readonly UserService _userService = new UserService();
protected void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,
IDMode = IDMode.Static
};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),
ID = "fp_1"
};
var btnreset = new Ext.Net.Button { Text = "取消", ID = "btn_reset", IDMode = IDMode.Static };
btnreset.Listeners.Click.Handler = "#{fp_1}.reset();";
var btnsubmit = new Ext.Net.Button { Text = "登录", ID = "btn_submit", IDMode = IDMode.Static };
btnsubmit.DirectEvents.Click.Event += Login;
fp.Buttons.Add(btnreset);
fp.Buttons.Add(btnsubmit);
var tfName = new TextField
{
ID = "tf_uname",
FieldLabel = "用户名",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70
};
var tfPass = new TextField
{
ID = "tf_pass",
FieldLabel = "密码",
AnchorHorizontal = "100%",
InputType = InputType.Password,
Margin = 4,
LabelWidth = 70
};
fp.Items.Add(tfName);
fp.Items.Add(tfPass);
var fc = new FieldContainer
{
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
FieldLabel = "验证码"
};
fc.LayoutConfig.Add(new HBoxLayoutConfig { Align = HBoxAlign.Middle });
var rand = new Random().Next(100000, 999999).ToString();
var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true,
IDMode = IDMode.Static
};

fc.Items.Add(dfYzm);
fc.Items.Add(new Component { Flex = 1 });
var btnfresh = new Ext.Net.Button { ID = "btn_refresh", Text = "刷新", IDMode = IDMode.Static };
btnfresh.DirectEvents.Click.Event += NewYzm;
fc.Items.Add(btnfresh);
fp.Items.Add(fc);
fp.Items.Add(new TextField
{
FieldLabel = "输入验证码",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
ID = "tf_yzm1"
});
var notlogin = new FieldContainer()
{
FieldLabel = "登录不上?",
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70

};
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_reg.aspx",
Text = "注册",
Margin = 4
});
notlogin.Items.Add(new Ext.Net.HyperLink()
{
NavigateUrl = "fenlei_index.aspx",
Text = "返回首页",
Margin = 4
});
fp.Items.Add(
notlogin
);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void NewYzm1()
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
private void Login(object sender, DirectEventArgs e)
{
var uname = Request["tf_uname"];

var pass = Request["tf_pass"];
var yzm = Request["tf_yzm"];
var yzm11 = Request["tf_yzm11"];

if (yzm == yzm11)
{
//if (_userService.Login(uname, pass))
//{
// var u = _userService.GetUserByName(uname);
// _userService.WriteSessionAndCookie(u);
// Response.Redirect("~/fenlei_user.aspx");
//}
//else
//{
// X.MessageBox.Alert("提示", "登陆失败").Show();
// NewYzm1();
//}
}
else
{
X.MessageBox.Alert("提示", "验证码不正确").Show();
NewYzm1();
}
}
}
}


14721

geoffrey.mcgill
Aug 22, 2014, 7:38 PM
Hello,

Are those Ext.Net.HyperLink components related to the problem?

hdsoso
Aug 23, 2014, 1:15 AM
i do not use hyperlink in my example code above. if do not use master page ,no error.

geoffrey.mcgill
Aug 23, 2014, 5:23 AM
I see Ext.Net.HyperLink controls in your code. If they are not related to the problem, please remove.

While you're at it, please remove all code that is not related to the problem. This is the same request we've made several times. If you cannot provide a code sample that demonstrates how to reproduce the problem with only code related to the problem, we cannot provide assistance.

hdsoso
Aug 23, 2014, 12:15 PM
new LoginPage1.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ext.Net;
using service.qizweb.com;

namespace webbase.qizweb.com
{
public class LoginPage1 : System.Web.UI.Page
{
//readonly UserService _userService = new UserService();
protected void CreateLoginWindow()
{
var window = new Ext.Net.Window
{
Title = "用户登录",
ID = "w_login",
Width = 300,
Modal = true,
Closable = false,
IDMode = IDMode.Static
};
var fp = new Ext.Net.FormPanel
{
Padding = 4,
Layout = LayoutType.Anchor.ToString(),
ID = "fp_1"
};
//var btnreset = new Ext.Net.Button { Text = "取消", ID = "btn_reset", IDMode = IDMode.Static };
//btnreset.Listeners.Click.Handler = "#{fp_1}.reset();";
//var btnsubmit = new Ext.Net.Button { Text = "登录", ID = "btn_submit", IDMode = IDMode.Static };
//btnsubmit.DirectEvents.Click.Event += Login;
//fp.Buttons.Add(btnreset);
//fp.Buttons.Add(btnsubmit);
//var tfName = new TextField
//{
// ID = "tf_uname",
// FieldLabel = "用户名",
// AnchorHorizontal = "100%",
// Margin = 4,
// LabelWidth = 70
//};
//var tfPass = new TextField
//{
// ID = "tf_pass",
// FieldLabel = "密码",
// AnchorHorizontal = "100%",
// InputType = InputType.Password,
// Margin = 4,
// LabelWidth = 70
//};
//fp.Items.Add(tfName);
//fp.Items.Add(tfPass);
var fc = new FieldContainer
{
AnchorHorizontal = "100%",
Margin = 4,
LabelWidth = 70,
FieldLabel = "验证码"
};
fc.LayoutConfig.Add(new HBoxLayoutConfig { Align = HBoxAlign.Middle });
var rand = new Random().Next(100000, 999999).ToString();
var dfYzm = new Ext.Net.TextField()
{
ID = "tf_yzm",
Text = rand,
Value = rand,
ReadOnly = true,
IDMode = IDMode.Static
};

fc.Items.Add(dfYzm);
fc.Items.Add(new Component { Flex = 1 });
var btnfresh = new Ext.Net.Button { ID = "btn_refresh", Text = "刷新", IDMode = IDMode.Static };
btnfresh.DirectEvents.Click.Event += NewYzm;
fc.Items.Add(btnfresh);
fp.Items.Add(fc);
//fp.Items.Add(new TextField
//{
// FieldLabel = "输入验证码",
// AnchorHorizontal = "100%",
// Margin = 4,
// LabelWidth = 70,
// ID = "tf_yzm1"
//});
//var notlogin = new FieldContainer()
//{
// FieldLabel = "登录不上?",
// AnchorHorizontal = "100%",
// Margin = 4,
// LabelWidth = 70

//};
//notlogin.Items.Add(new Ext.Net.HyperLink()
//{
// NavigateUrl = "fenlei_reg.aspx",
// Text = "注册",
// Margin = 4
//});
//notlogin.Items.Add(new Ext.Net.HyperLink()
//{
// NavigateUrl = "fenlei_index.aspx",
// Text = "返回首页",
// Margin = 4
//});
//fp.Items.Add(
// notlogin
//);
window.Items.Add(fp);
this.Form.Controls.Add(window);
}

private void NewYzm(object sender, DirectEventArgs e)
{
var rand = new Random().Next(100000, 999999).ToString();
X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
}
//private void NewYzm1()
//{
// var rand = new Random().Next(100000, 999999).ToString();
// X.GetCmp<Ext.Net.TextField>("tf_yzm").Text = rand;
//}
//private void Login(object sender, DirectEventArgs e)
//{
// var uname = Request["tf_uname"];

// var pass = Request["tf_pass"];
// var yzm = Request["tf_yzm"];
// var yzm11 = Request["tf_yzm11"];

// if (yzm == yzm11)
// {
// //if (_userService.Login(uname, pass))
// //{
// // var u = _userService.GetUserByName(uname);
// // _userService.WriteSessionAndCookie(u);
// // Response.Redirect("~/fenlei_user.aspx");
// //}
// //else
// //{
// // X.MessageBox.Alert("提示", "登陆失败").Show();
// // NewYzm1();
// //}
// }
// else
// {
// X.MessageBox.Alert("提示", "验证码不正确").Show();
// NewYzm1();
// }
//}
}
}


i remove all unused code .

hdsoso
Aug 28, 2014, 3:02 PM
@geoffrey.mcgill
thought i change another way to do this. but i think it is ext.net's bug, i have written a test case above , you can just copy/paste the code to your work unless you do not think user's feedback is important. I am very seriouse for the issue and i do not know I made what wrong?

Daniil
Sep 05, 2014, 9:08 AM
i remove all unused code .

As far as I can see you have commented the code out, not removed.