调用这样的控制器动作时:
控制器/动作
一切都很好。但是当使用id参数调用相同的动作时:控制器/动作/ ID
离。家/索引/ 10
视图似乎没有根据mu css-file ....
呈现任何对此有所了解的人?
呼叫:
<INPUT class="btn btn-default" type="button" value="Last" onclick="window.location.href = '/Home/Statistics/4'">
动作
public ActionResult Statistics(string id)
控制器:
public class HomeController : Controller
{
public ActionResult Index()
{
Variables.logInStatusAvtiveUser = "notActive";
return View();
}
public ActionResult Home()
{
if (Variables.logInStatusAvtiveUser == "active")
{
string[] nameCampain = { "Omega3", "VitaminC", "VitaminD" };
string[] doublets = { "34", "22", "21" };
string[] customer = { "21", "12", "11" };
string[] hit = { "2", "4", "6" };
string[] nonValid = { "11", "12", "13" };
string[] batch = { "30", "40", "20" };
string[] batchActual = { "30", "40", "20" };
string[] total = { "30", "40", "20" };
string[] totalActual = { "30", "40", "20" };
string[] feedBackActual = { "30", "40", "20" };
ViewBag.chart = CToHTML.CreateHTMLChart(nameCampain, doublets, customer, hit, nonValid, batch, batchActual, total, totalActual, feedBackActual);
return View();
}
else
{
return RedirectToAction("Index", "Home");
}
}
public ActionResult Database()
{
if (Variables.logInStatusAvtiveUser == "active")
{
return View();
}
else
{
return RedirectToAction("Index", "Home");
}
}
public ActionResult Statistics(string id)
{
if (Variables.logInStatusAvtiveUser == "active")
{
string q = "`Name`,`Family Name`,`Gender`,`Zip Code`,`Town`,`Adress`";
MySqlBinding dbConn = new MySqlBinding(Variables.serverActiveUser, Variables.portActiveUser, Variables.databaseActiveUser, Variables.usernameActiveUser, Variables.passwordActiveUser);
if (id == "1")
{
ViewBag.DB = CToHTML.ConvertDataTableToHTML(dbConn.SelectFromDT(Variables.databaseActiveUser, "Leads", q, "0", "50"));
}
if (id == "2")
{
ViewBag.DB = CToHTML.ConvertDataTableToHTML(dbConn.SelectFromDT(Variables.databaseActiveUser, "Leads", q, "50", "100"));
}
if (id == "3")
{
ViewBag.DB = CToHTML.ConvertDataTableToHTML(dbConn.SelectFromDT(Variables.databaseActiveUser, "Leads", q, "100", "150"));
}
if (id == "4")
{
ViewBag.DB = CToHTML.ConvertDataTableToHTML(dbConn.SelectFromDT(Variables.databaseActiveUser, "Leads", q, "150", "200"));
}
return View();
}
else
{
return RedirectToAction("Index", "Home");
}
}
}
查看:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<title>Sticky Footer Navbar Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="../css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="sticky-footer-navbar.css" rel="stylesheet">
<%@ Import Namespace="CAIUGO_UI_BOOTSTRAP_V2" %>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<form id="form1" runat="server">
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">CAIUGO</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="Home">Home</a></li>
<li><a href="Database">Database</a></li>
<li class="active"><a href="Statistics">Statistics</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<table style="width: 100%; margin-top: 100px;">
<tr>
<td style="width: 10%"> </td>
<td style="width: 60%"> </td>
<td style="width: 20%">
<div class="pull-right">
<INPUT class="btn btn-default" type="button" value="First" onclick="window.location.href = '/Home/Statistics/1'">
<INPUT class="btn btn-default" type="button" value="<-" onclick="window.location.href = '/Home/Statistics/2'">
<INPUT class="btn btn-default" type="button" value="->" onclick="window.location.href = '/Home/Statistics/3'">
<INPUT class="btn btn-default" type="button" value="Last" onclick="window.location.href = '/Home/Statistics/4'">
</div>
</td>
<td style="width: 10%"></td>
</tr>
</table>
<table style="width: 100%">
<tr>
<td style="width: 10%"> </td>
<% dataTable.InnerHtml = ViewBag.DB;%>
<td id="dataTable" runat="server">
<%-- Autocreated HTML Table here --%>
</td>
<td style="width: 10%"> </td>
</tr>
</table>
</div>
<!-- Begin page content -->
<div style="height: auto; width: 80%">
</div>
<div id="footer">
<div class="container">
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
</form>
</body>
</html>
答案 0 :(得分:0)
如果未应用css,则意味着未加载css文件,因为它可能是由于css文件url问题,你需要做的是使用@Url.Content()
helper for css和js file include如下:
<link href="@Url.Content("~/css/bootstrap.css")" rel="stylesheet">
和js文件:
<script src="@Url.Content("~/js/bootstrap.min.js")"></script>
和ico图标:
<link rel="shortcut icon" href="@Url.Content("~/docs-assets/ico/favicon.png")">
此方法也应该应用于视图中的img标记,否则您会遇到有时因错误的网址而无法加载图片。
这会从相对网址生成正确的网址,以便在视图中加载css和js。
你可以在这里看到,为什么要使用它:
Why should I use @Url.Content("~/blah-blah-blah")?
这里是MSDN docs