1.CSS文件代码:
function AddItem_LearningExperience(school, beginTime, endTime, speciality, isPublic){
var divContainer = $("#divContainerLearningExperience");
var txtItemCount = $("#txtItemCountLearningExperience");
if(divContainer != null && txtItemCount != null){
var table = $("<table width='610' border='0' align='center' cellpadding='0' cellspacing='0'></table>");
var tr1 = $("<tr></tr>");
var td1_1 = $("<td class='login' style='width: 35%;'> 所在学校:</td>");
var td1_2 = $("<td colspan='2' class='login'></td>");
var td1_2_text = $("<input></input>");
td1_2_text.attr("type", "text");
td1_2_text.attr("id", "txtLearningExperienceSchool" + txtItemCount.val());
td1_2_text.attr("name", "txtLearningExperienceSchool" + txtItemCount.val());
td1_2_text.attr("size", "30");
td1_2_text.attr("value", school);
td1_2.append(td1_2_text);
if(txtItemCount.val() != 0){
td1_2_a = $("<img src='../images/items_delete.gif' border='0' style='cursor:pointer;'/>");
td1_2_a.click(function(){
table.remove();
});
td1_2.append(td1_2_a);
}
tr1.append(td1_1);
tr1.append(td1_2);
var tr2 = $("<tr></tr>");
var td2_1 = $("<td class='login'>时间:</td>");
var td2_2 = $("<td colspan='2' class='login'></td>");
var td2_2_beginTime = $("<input></input>");
td2_2_beginTime.attr("type", "text");
td2_2_beginTime.attr("id", "txtLearningExperienceBeginTime" + txtItemCount.val());
td2_2_beginTime.attr("name", "txtLearningExperienceBeginTime" + txtItemCount.val());
td2_2_beginTime.css("width", "80px");
td2_2_beginTime.attr("value", beginTime);
var td2_2_endTime = $("<input></input>");
td2_2_endTime.attr("type", "text");
td2_2_endTime.attr("id", "txtLearningExperienceEndTime" + txtItemCount.val());
td2_2_endTime.attr("name", "txtLearningExperienceEndTime" + txtItemCount.val());
td2_2_endTime.css("width", "80px");
td2_2_endTime.attr("value", endTime);
td2_2.append(td2_2_beginTime);
td2_2.append(" - ");
td2_2.append(td2_2_endTime);
tr2.append(td2_1);
tr2.append(td2_2);
var tr3 = $("<tr></tr>");
var td3_1 = $("<td class='login'>专业:</td>");
var td3_2 = $("<td colspan='2' class='login'></td>");
var td3_2_text = $("<input/>");
td3_2_text.attr("type", "text");
td3_2_text.attr("id", "txtLearningExperienceSpeciality" + txtItemCount.val());
td3_2_text.attr("name", "txtLearningExperienceSpeciality" + txtItemCount.val());
td3_2_text.attr("size", "30");
td3_2_text.attr("value", speciality);
td3_2.append(td3_2_text);
tr3.append(td3_1);
tr3.append(td3_2);
var tr4 = $("<tr></tr>");
var td4_1 = $("<td class='login'>可见性:</td>");
var td4_2 = $("<td colspan='2' class='login'></td>");
// IE6不兼容
// var td4_2_radio1 = $("<input></input>");
// td4_2_radio1.attr("type", "radio");
// td4_2_radio1.attr("value", 1);
// td4_2_radio1.attr("name", "LearningExperienceIsPublic");
// td4_2_radio1.attr("id", "rdoLearningExperienceIsPublicTrue" + txtItemCount.val());
// var td4_2_radio2 = $("<input></input>");
// td4_2_radio2.attr("type", "radio");
// td4_2_radio2.attr("value", 0);
// td4_2_radio2.attr("name", "LearningExperienceIsPublic");
// td4_2_radio2.attr("id", "rdoLearningExperienceIsPublicFalse" + txtItemCount.val());
// td4_2.append(td4_2_radio1);
// td4_2.append("所有人");
// td4_2.append(td4_2_radio2);
// td4_2.append("只有我");
var rdoWorkExperienceIsPublicTrue_htmlString = "<input id='rdoLearningExperienceIsPublicTrue" + txtItemCount.val() + "' type='radio' value='1' name='LearningExperienceIsPublic" + txtItemCount.val() + "' ";
var rdoWorkExperienceIsPublicFalse_htmlString ="<input id='rdoLearningExperienceIsPublicFalse" + txtItemCount.val() + "' type='radio' value='0' name='LearningExperienceIsPublic" + txtItemCount.val() + "'";
if(isPublic == 1){
rdoWorkExperienceIsPublicTrue_htmlString += " checked='checked'";
}
else{
rdoWorkExperienceIsPublicFalse_htmlString += " checked='checked'";
}
rdoWorkExperienceIsPublicTrue_htmlString += "/>所有人";
rdoWorkExperienceIsPublicFalse_htmlString += " />只有我";
td4_2.append(rdoWorkExperienceIsPublicTrue_htmlString);
td4_2.append(rdoWorkExperienceIsPublicFalse_htmlString);
tr4.append(td4_1);
tr4.append(td4_2);
table.append(tr1);
table.append(tr2);
table.append(tr3);
table.append(tr4);
divContainer.append(table);
txtItemCount.val(parseInt(txtItemCount.val()) + 1);
}
}
2.ASPX页面相关代码:
<table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" class="profile_t" style="width: 35%;">
学习经历
</td>
<td height="26" align="left">
</td>
</tr>
</table>
<div id="divContainerLearningExperience">
</div>
<input id="txtItemCountLearningExperience" name="txtItemCountLearningExperience"
type="hidden" value="0" />
<table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="13" colspan="3" align="left">
<img src="../images/add.jpg" width="12" height="12" />
<a class="inbox_r_n" href="javascript:void(0);" οnclick="AddItem_LearningExperience('','','','','1');">
Add New</a>
</td>
</tr>
</table>
3.ASPX.CS后台相关代码:
/// <summary>
/// 绑定学习经历表单
/// </summary>
private void SetItems_LearningExperience()
{
DataSet ds = new UserBLL.LearningExperienceManager().GetList(null, this.Page.User.Identity.Name, Convert.ToInt32(SystemModel.ELanguages.English));
string script = null;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
script = string.Format(
"AddItem_LearningExperience('{0}','{1}','{2}','{3}','{4}');",
new string[] { row["SCHOOL_NAME"].ToString(), Shundao.Common.DataFormat.FormatDateTime(row["BEGIN_TIME"]), Shundao.Common.DataFormat.FormatDateTime(row["END_TIME"]), row["SPECIALITY"].ToString(), Convert.ToBoolean(row["IS_PUBLIC"]) ? "1" : "0" });
base.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), script, true);
}
}
else
{
base.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "AddItem_LearningExperience('','','','','1');", true);
}
}
/// <summary>
/// 保存学习经历表单数据
/// </summary>
private void GetItems_LearningExperience()
{
UserBLL.LearningExperienceManager bll = new UserBLL.LearningExperienceManager();
bll.DeleteByUserId(this.Page.User.Identity.Name, Convert.ToInt32(SystemModel.ELanguages.English));
int txtItemCount = Shundao.Common.DataConvert.GetInt32(Request.Form["txtItemCountLearningExperience"]);
UserModel.LearningExperience model = new UserModel.LearningExperience();
for (int i = 0; i < txtItemCount; i++)
{
model.SCHOOL_NAME = Request.Form["txtLearningExperienceSchool" + i];
model.BEGIN_TIME = Shundao.Common.DataConvert.GetDateTime(Request.Form["txtLearningExperienceBeginTime" + i], null);
model.END_TIME = Shundao.Common.DataConvert.GetDateTime(Request.Form["txtLearningExperienceEndTime" + i], null);
model.SPECIALITY = Request.Form["txtLearningExperienceSpeciality" + i];
model.IS_PUBLIC = Request.Form["LearningExperienceIsPublic" + i] == "1" ? true : false;
model.USER_ID = Convert.ToInt32(this.Page.User.Identity.Name);
model.LANGUAGE = Convert.ToInt32(SystemModel.ELanguages.English);
if (!string.IsNullOrEmpty(model.SCHOOL_NAME))
{
bll.Add(model);
}
}
}
function AddItem_LearningExperience(school, beginTime, endTime, speciality, isPublic){
var divContainer = $("#divContainerLearningExperience");
var txtItemCount = $("#txtItemCountLearningExperience");
if(divContainer != null && txtItemCount != null){
var table = $("<table width='610' border='0' align='center' cellpadding='0' cellspacing='0'></table>");
var tr1 = $("<tr></tr>");
var td1_1 = $("<td class='login' style='width: 35%;'> 所在学校:</td>");
var td1_2 = $("<td colspan='2' class='login'></td>");
var td1_2_text = $("<input></input>");
td1_2_text.attr("type", "text");
td1_2_text.attr("id", "txtLearningExperienceSchool" + txtItemCount.val());
td1_2_text.attr("name", "txtLearningExperienceSchool" + txtItemCount.val());
td1_2_text.attr("size", "30");
td1_2_text.attr("value", school);
td1_2.append(td1_2_text);
if(txtItemCount.val() != 0){
td1_2_a = $("<img src='../images/items_delete.gif' border='0' style='cursor:pointer;'/>");
td1_2_a.click(function(){
table.remove();
});
td1_2.append(td1_2_a);
}
tr1.append(td1_1);
tr1.append(td1_2);
var tr2 = $("<tr></tr>");
var td2_1 = $("<td class='login'>时间:</td>");
var td2_2 = $("<td colspan='2' class='login'></td>");
var td2_2_beginTime = $("<input></input>");
td2_2_beginTime.attr("type", "text");
td2_2_beginTime.attr("id", "txtLearningExperienceBeginTime" + txtItemCount.val());
td2_2_beginTime.attr("name", "txtLearningExperienceBeginTime" + txtItemCount.val());
td2_2_beginTime.css("width", "80px");
td2_2_beginTime.attr("value", beginTime);
var td2_2_endTime = $("<input></input>");
td2_2_endTime.attr("type", "text");
td2_2_endTime.attr("id", "txtLearningExperienceEndTime" + txtItemCount.val());
td2_2_endTime.attr("name", "txtLearningExperienceEndTime" + txtItemCount.val());
td2_2_endTime.css("width", "80px");
td2_2_endTime.attr("value", endTime);
td2_2.append(td2_2_beginTime);
td2_2.append(" - ");
td2_2.append(td2_2_endTime);
tr2.append(td2_1);
tr2.append(td2_2);
var tr3 = $("<tr></tr>");
var td3_1 = $("<td class='login'>专业:</td>");
var td3_2 = $("<td colspan='2' class='login'></td>");
var td3_2_text = $("<input/>");
td3_2_text.attr("type", "text");
td3_2_text.attr("id", "txtLearningExperienceSpeciality" + txtItemCount.val());
td3_2_text.attr("name", "txtLearningExperienceSpeciality" + txtItemCount.val());
td3_2_text.attr("size", "30");
td3_2_text.attr("value", speciality);
td3_2.append(td3_2_text);
tr3.append(td3_1);
tr3.append(td3_2);
var tr4 = $("<tr></tr>");
var td4_1 = $("<td class='login'>可见性:</td>");
var td4_2 = $("<td colspan='2' class='login'></td>");
// IE6不兼容
// var td4_2_radio1 = $("<input></input>");
// td4_2_radio1.attr("type", "radio");
// td4_2_radio1.attr("value", 1);
// td4_2_radio1.attr("name", "LearningExperienceIsPublic");
// td4_2_radio1.attr("id", "rdoLearningExperienceIsPublicTrue" + txtItemCount.val());
// var td4_2_radio2 = $("<input></input>");
// td4_2_radio2.attr("type", "radio");
// td4_2_radio2.attr("value", 0);
// td4_2_radio2.attr("name", "LearningExperienceIsPublic");
// td4_2_radio2.attr("id", "rdoLearningExperienceIsPublicFalse" + txtItemCount.val());
// td4_2.append(td4_2_radio1);
// td4_2.append("所有人");
// td4_2.append(td4_2_radio2);
// td4_2.append("只有我");
var rdoWorkExperienceIsPublicTrue_htmlString = "<input id='rdoLearningExperienceIsPublicTrue" + txtItemCount.val() + "' type='radio' value='1' name='LearningExperienceIsPublic" + txtItemCount.val() + "' ";
var rdoWorkExperienceIsPublicFalse_htmlString ="<input id='rdoLearningExperienceIsPublicFalse" + txtItemCount.val() + "' type='radio' value='0' name='LearningExperienceIsPublic" + txtItemCount.val() + "'";
if(isPublic == 1){
rdoWorkExperienceIsPublicTrue_htmlString += " checked='checked'";
}
else{
rdoWorkExperienceIsPublicFalse_htmlString += " checked='checked'";
}
rdoWorkExperienceIsPublicTrue_htmlString += "/>所有人";
rdoWorkExperienceIsPublicFalse_htmlString += " />只有我";
td4_2.append(rdoWorkExperienceIsPublicTrue_htmlString);
td4_2.append(rdoWorkExperienceIsPublicFalse_htmlString);
tr4.append(td4_1);
tr4.append(td4_2);
table.append(tr1);
table.append(tr2);
table.append(tr3);
table.append(tr4);
divContainer.append(table);
txtItemCount.val(parseInt(txtItemCount.val()) + 1);
}
}
2.ASPX页面相关代码:
<table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" class="profile_t" style="width: 35%;">
学习经历
</td>
<td height="26" align="left">
</td>
</tr>
</table>
<div id="divContainerLearningExperience">
</div>
<input id="txtItemCountLearningExperience" name="txtItemCountLearningExperience"
type="hidden" value="0" />
<table width="610" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="13" colspan="3" align="left">
<img src="../images/add.jpg" width="12" height="12" />
<a class="inbox_r_n" href="javascript:void(0);" οnclick="AddItem_LearningExperience('','','','','1');">
Add New</a>
</td>
</tr>
</table>
3.ASPX.CS后台相关代码:
/// <summary>
/// 绑定学习经历表单
/// </summary>
private void SetItems_LearningExperience()
{
DataSet ds = new UserBLL.LearningExperienceManager().GetList(null, this.Page.User.Identity.Name, Convert.ToInt32(SystemModel.ELanguages.English));
string script = null;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
script = string.Format(
"AddItem_LearningExperience('{0}','{1}','{2}','{3}','{4}');",
new string[] { row["SCHOOL_NAME"].ToString(), Shundao.Common.DataFormat.FormatDateTime(row["BEGIN_TIME"]), Shundao.Common.DataFormat.FormatDateTime(row["END_TIME"]), row["SPECIALITY"].ToString(), Convert.ToBoolean(row["IS_PUBLIC"]) ? "1" : "0" });
base.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), script, true);
}
}
else
{
base.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "AddItem_LearningExperience('','','','','1');", true);
}
}
/// <summary>
/// 保存学习经历表单数据
/// </summary>
private void GetItems_LearningExperience()
{
UserBLL.LearningExperienceManager bll = new UserBLL.LearningExperienceManager();
bll.DeleteByUserId(this.Page.User.Identity.Name, Convert.ToInt32(SystemModel.ELanguages.English));
int txtItemCount = Shundao.Common.DataConvert.GetInt32(Request.Form["txtItemCountLearningExperience"]);
UserModel.LearningExperience model = new UserModel.LearningExperience();
for (int i = 0; i < txtItemCount; i++)
{
model.SCHOOL_NAME = Request.Form["txtLearningExperienceSchool" + i];
model.BEGIN_TIME = Shundao.Common.DataConvert.GetDateTime(Request.Form["txtLearningExperienceBeginTime" + i], null);
model.END_TIME = Shundao.Common.DataConvert.GetDateTime(Request.Form["txtLearningExperienceEndTime" + i], null);
model.SPECIALITY = Request.Form["txtLearningExperienceSpeciality" + i];
model.IS_PUBLIC = Request.Form["LearningExperienceIsPublic" + i] == "1" ? true : false;
model.USER_ID = Convert.ToInt32(this.Page.User.Identity.Name);
model.LANGUAGE = Convert.ToInt32(SystemModel.ELanguages.English);
if (!string.IsNullOrEmpty(model.SCHOOL_NAME))
{
bll.Add(model);
}
}
}