MVC问题反馈页面代码

view:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<link href="./http://www.cnblogs.com/Content/jquery/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<link href="./http://www.cnblogs.com/Content/site.css" rel="stylesheet" type="text/css" />
<link href="./http://www.cnblogs.com/Content/styles/respond.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./../Content/jquery/jquery.min.js"></script>
<script type="text/javascript" src="./../Content/jquery/jquery.ui.min.js"></script>
<script type="text/javascript" src="./../Content/scripts/utils.js"></script>
<script type="text/javascript" src="./../Content/scripts/main/respond.js"></script>
</head>
<body>
<div id="wrap">
<div id="header"><h2>信息反馈<a class="back" href="#" title="返回前页">返回</a></h2></div>
<div id="main">
<form id="respond" name="respond" action="" method="post">
<p><label for="respondName">提交人:</label><input id="respondName" name="respondName" type="text" value="<% Response.Write(((DashboardDfx.Applications.Authen.LoginUser)Session["LoginUser"]).ENName); %>" readonly="readonly" /></p>
<p><label for="respondURL">问题发生页面:</label><input id="respondURL" name="respondURL" type="text" value="相关页面地址" readonly="readonly" /></p>
<p><label for="respondType">反馈类型:</label>
<select id="respondType" name="respondType">
<option value="advice">建议</option>
<option value="demand">需求</option>
<option value="bug">BUG</option>
</select>
</p>
<p class="textarea"><label for="respondText">反馈内容:</label><textarea id="respondText" name="respondText" cols="100" rows="100">请填写反馈内容,我们将尽快处理。感谢您的支持 :)</textarea></p>
<p class="submit"><input id="respondSubmit" class="button" name="respondSubmit" type="submit" value="提交反馈" /></p>
</form>
</div>
<div id="thanks" class="hide">
<p>感谢您的反馈!&nbsp;&nbsp;<strong id="num">5</strong>&nbsp;&nbsp;秒后自动返回 ...</p>
<p><a class="back" href="#">点此链接直接返回</a></p>
</div>
</div>
<div class="alert-box" title="标题"></div>

</body>
</html>

 

js:
jQuery(function($) {
var ieVer = ieVersion();
//去除无用元素
$(window.parent.document).find('#navigatorDiv').hide();
//表单
$('#respondText').data('val',$('#respondText').val()).focus(function(){
var val = $(this).data('val');
if($(this).val()==val){
$(this).empty();
}
}).blur(function(){
var val = $(this).data('val');
if($(this).val()==''){
$(this).text(val);
}
}).click(function(){
$(this).focus();
});
//URL
//var resURL = $(window.parent.document).find('#mainFrm').attr('rel');
//var resURL = getCookie('prev_href');
var resURL = window.location.href.split('#');
resURL = resURL[1];
if(resURL=='VisitReport'){
$('#wrap').css('margin','0 auto 0 100px');
}
$('#respondURL').attr('value',resURL);
//submit
$('#respond').submit(function(){
var respondName = $('#respondName').val();
var respondType = $('#respondType').val();
var respondText = replaceText($('#respondText').val());
var respondURL = $('#respondURL').val();
respondURL = respondURL.length>512 ? respondURL.substring(respondURL.length-510,respondURL.length) : respondURL; //截取过长的URL

if(respondText=='' || respondText==$('#respondText').data('val')){
alertBox('请填写完整信息','请填写反馈内容','warning');
$('#respondText').addClass('highlight').focus();
return false;
} else {
var values = {
name : respondName,
type : respondType,
url : respondURL,
content : respondText
};
var param = $.param(values);
//alert(param);
$.ajax({
type : 'POST',
url : 'InsertRespond',
dataType : 'json',
data : param,
error :function(msg){
alertBox('提交失败',msg,'error');
return false;
},
success : function(msg){
$('#header h2').html('提交成功!');
$('#main').addClass('hide').next().removeClass('hide');
setT();
return false;
}
});
return false;
}
});
//highlight
$('#respondType,#respondText').change(function(){
$(this).removeClass('highlight');
$('#respondText').focus();
});
//回退
$('a.back').click(function(){
window.history.back(-1);
return false;
});
//setT();
//End
});
//Functions
var countTime = 5;
var setT = function(){
$('#num').empty().text(countTime);
countTime--;
if(countTime>0){
setTimeout(function(){setT();},800);
} else {
window.history.back(-1);
}
};

 

Controller:
public ActionResult InsertRespond(string name,string url,string content,string type)
{
try
{
mainRepository.InsertRespond(name, url, content, type);
}
catch (Exception)
{
return Json(new { res = false, message = "" }, JsonRequestBehavior.AllowGet);
throw;
}

return Json(new { res = true, message = "" }, JsonRequestBehavior.AllowGet);
}

 

Model:
public void InsertRespond(string name, string url, string content, string type)
{
SYS_RESPOND_LIST respond = new SYS_RESPOND_LIST();

respond.content = content;
respond.name = name;
respond.time = DateTime.Now;
respond.type = type;
respond.url = url;

context.SYS_RESPOND_LIST.InsertOnSubmit(respond);
context.SubmitChanges();

}

posted on 2012-01-08 09:23  cw_volcano  阅读(258)  评论(0编辑  收藏  举报