Bootstrap v3 and Kendo UI Grid 100% height - c#
I recently started working on a new project and this time around, I started off with a clean INSPINIA v2.7 theme. I used an empty page template from that theme and started building a simple search page with some filters and a functioning Kendo Grid.
Now, this website will be published to two orientation of screens: Landscape 1920 x 1080 and Portrait 1600 x 2560. I need to make the Kendo Grid behave accordingly. I google myself to this guide: Resize and Expand the Kendo UI Grid to 100% Height. I see that the first case is what I need. But there is a very simple container hierarchy there and the demo works very well.
In a bootstrap powered website, the hierarchy is not that simple.
Here is the _Layout.cshtml:
#using DA.Services.IBS.Web.FinancePortalFull.Helpers
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#">
<head>
<title>#ViewBag.Title | Finance System</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
<!-- Add local styles, mostly for plugins css file -->
#if (IsSectionDefined("Styles"))
{
#RenderSection("Styles", required: false)
}
<!-- Add jQuery Style direct - used for jQGrid plugin -->
<link href="#Url.Content("~/Scripts/plugins/jquery-ui/jquery-ui.min.css")" rel="stylesheet" type="text/css" />
<!-- Primary Inspinia style -->
#Styles.Render("~/Content/css")
#Styles.Render("~/font-awesome/css")
</head>
<body class="md-skin">
<!-- Wrapper-->
<!-- PageClass give you ability to specify custom style for specific view based on action -->
<div id="wrapper" class="#Html.PageClass()">
<!-- Navigation -->
#Html.Partial("_Navigation")
<!-- Page wraper -->
<div id="page-wrapper" class="gray-bg #ViewBag.SpecialClass">
<!-- Top Navbar -->
#Html.Partial("_TopNavbar")
<!-- Main view -->
#RenderBody()
<!-- Footer -->
#Html.Partial("_Footer")
</div>
<!-- End page wrapper-->
</div>
<!-- End wrapper-->
<!-- Section for main scripts render -->
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#Scripts.Render("~/bundles/kendo")
#Scripts.Render("~/plugins/slimScroll")
#Scripts.Render("~/bundles/inspinia")
<!-- Handler for local scripts -->
#RenderSection("scripts", required: false)
</body>
</html>
And below is the View itself. I have tried to follow the guide on the kendo link by adding the parent div at different levels but the div and the grid within doesn't render 100% at all.
#model DA.Services.IBS.Web.FinancePortalFull.Models.EpayTransactionFilterViewModel
#{
ViewBag.Title = "Filter";
}
<div class="row wrapper border-bottom white-bg page-heading">
<div class="col-lg-10">
<h2>#ViewBag.Title</h2>
<ol class="breadcrumb">...</ol>
</div>
<div class="col-lg-2">...</div>
</div>
<div class="wrapper wrapper-content animated fadeInRight">
<form method="post" action="#Url.Action("FilterReport", "EpayReconcile")">
<div class="ibox-content m-b-sm border-bottom">
<div class="row">
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
</div>
<div class="row">...</div>
<div class="row">...</div>
</div>
<div id="parent">
<div class="ibox">
<div class="ibox-content m-b-sm border-bottom">
<div class="row">
<div class="col-lg-12">
#(Html.Kendo().Grid(Model.SearchResults).Name("GridSearchResults")...)
</div>
</div>
</div>
</div>
</div>
</form>
</div>
#section Styles {
#Styles.Render("~/plugins/dataPickerStyles")
#Styles.Render("~/Content/plugins/chosen/chosenStyles")
<style>
html,
body,
#parent,
#GridSearchResults {
margin: 0;
padding: 0;
border-width: 0;
height: 100%; /* DO NOT USE !important for setting the Grid height! */
}
html
{
overflow: hidden;
font: 13px sans-serif;
}
</style>
}
#section Scripts {
#Scripts.Render("~/plugins/dataPicker")
#Scripts.Render("~/plugins/chosen")
<script type="text/javascript">
var gridElement = $("#GridSearchResults");
function resizeGrid() {
gridElement.data("kendoGrid").resize();
}
$(window).resize(function(){
resizeGrid();
});
</script>
}
Also, just for reference, the two screenshots from respective screens:
I need to know how to make the grid and the required containers and divs expand vertically as per viewport
If this is successful, I'll attempt to deal with dynamic page sizing so that maximum data can be displayed
Update:
I have this dojo: http://dojo.telerik.com/#DoomerDGR8/owoSeN
It works perfectly keeping performance in mind. I just need to make it work for all the containers and panels starting from _Layout.cshtml all the way down to my cshtml.
Update 2:
I added this style to the target view with the grid:
<style>
#GridSearchResults {
border-width: 0;
width: 100%;
height: 100%;
min-height: 100%;
}
html, body {
height:100%;
}
.fill {
min-height: 100%;
height: 100%;
}
html
{
overflow:hidden;
}
</style>
Also, modified script, view with grid only:
<script type="text/javascript">
$(document).ready(function () {
setPageSize();
});
function resizeGrid() {
var gridElement = $("#GridSearchResults");
// console.log(gridElement);
gridElement.data("kendoGrid").resize();
setPageSize();
}
function setPageSize(){
var grid = $("#GridSearchResults").data("kendoGrid");
var windowHeight = $(window).height();
//Custom Logic for pageSize
if (windowHeight >= 1200) {
grid.dataSource.pageSize(40);
}
else if (windowHeight >= 1000) {
grid.dataSource.pageSize(35);
}
else if(windowHeight >= 900){
grid.dataSource.pageSize(30);
}
else if(windowHeight >= 700){
grid.dataSource.pageSize(25);
}
else if(windowHeight >= 400){
grid.dataSource.pageSize(20);
}else{
grid.dataSource.pageSize(10);
}
}
$(window).resize(function(){
resizeGrid();
});
</script>
I still get no resizing effect and the grid remains fixed width as shown in earlier screenshots yet the JS is working. Here is what chrome inspects and it is all wrong as my height directives are being overridden at various places:
You'll notice I added the fill class to the page wrapper in _layout.cshtml that will only get applied if user is on the target view where .fill is defined.
No avail.
Related
Net Core: Write Unit Test Case for Slideshow Carousel
I created a Bootstrap Slideshow and several card components. How would I even begin testing that the slideshow works with Xunit? I need to ensure that the slider, left right arrows actually work, that they render the same picture, that the captions show. I added some custom code. How would I write a webtest to ensure that slide arrows work for example? https://getbootstrap.com/docs/4.0/components/carousel/ .imgcarousel { width:100%; } .carouselleftarrow { font-family: Material Icons; position: absolute; bottom: 5px; content: "\e408"; } .carouselrightarrow { font-family: Material Icons; position: absolute; bottom: 5px; content: "\e409"; } <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css"> <!-- jQuery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <!-- Latest compiled JavaScript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script> <div class="carousel slide" data-ride="carousel" id="Carouselid0efe5f93f1734c5a967cf4ff7c47775a" style=" width: 500px; height: 500px;"> <ol class="carousel-indicators"> <li data-slide-to="0" data-target="#Carouselid0efe5f93f1734c5a967cf4ff7c47775a" class=""></li> <li data-slide-to="1" data-target="#Carouselid0efe5f93f1734c5a967cf4ff7c47775a" class=""></li> <li data-slide-to="2" data-target="#Carouselid0efe5f93f1734c5a967cf4ff7c47775a" class="active"></li> </ol> <div class="carousel-inner"> <div class="item"><img class="imgcarousel mCS_img_loaded" src="https://www.woodlandtrust.org.uk/media/100078482/Sycamore01.jpg?cb=-11897985&preset=gallery-tab-main-image"></div> <div class="item"><img class="imgcarousel mCS_img_loaded" src="https://statesymbolsusa.org/sites/statesymbolsusa.org/files/styles/symbol_thumbnail__medium/public/primary-images/Applesfreshpicked.jpg?itok=YmYkBfY7"></div> <div class="item active"><img class="imgcarousel mCS_img_loaded" src="https://www.mcpl.us/sites/default/files/styles/large/public/bookstack.jpg?itok=pHICdzg9"></div> </div> <a class="left carousel-control" data-slide="prev" href="#Carouselid0efe5f93f1734c5a967cf4ff7c47775a"><span class="carouselleftarrow">navigate_before</span></a><a class="right carousel-control" data-slide="next" href="#Carouselid0efe5f93f1734c5a967cf4ff7c47775a"><span class="carouselrightarrow">navigate_next</span></a> </div>
Something like: public class MyTests { private IWebDriver _webdriver = new ChromeDriver(); [Fact] public void CarouselWithMultipleItems_ClickRightButton_NavigatesToNextItem() { // Arrange // Load page _webdriver.Url = "your-url-here"; // Wait until right button is clickable WebDriverWait wait = new WebDriverWait(_webdriver, new TimeSpan(0, 0, 30)); WebElement rightArrow = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.CssSelector("a.right.carousel-control"))); // Act rightArrow.Click(); // Assert WebElement caption = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("<caption-selector-here>"))); // You might need another wait here WebElement picture = _webdriver.FindElement(By.CssSelector(".imgcarousel.active")); // Do your assert logic here } } Should get you started. It goes without saying that you will need to include the relevant xUnit NuGet pacakges along with the Selenium.WebDriver, Selenium.Support, SeleniumChrome.WebDriver, and DotNetSeleniumExtras (there might be some other required ones too).
How to use multiple layouts in a single view
I'm developing an asp.net mvc web application for the first time. When creating the project by default we get a proper template. In that template I want to add an image slider on top of it while default format also kept as it. Keeping everything as it is, I create another view called ImageSlider.cshtml and called it within Index.cshtml file. However image slider was working perfectly. But earlier default layout is missing now. How it is now How I wanted it to be. This format + image slider Index.cshtml #{ ViewBag.Title = "Sri Lanka Railway Department - Home"; Layout = "~/Views/Home/ImageSlider.cshtml"; } <div class="row"> <div class="col-md-4"> <h2>Transactions</h2> <p>Click below link to view your Account Transaction History and Account Balance</p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p> </div> <div class="col-md-4"> <h2>Top Up</h2> <p>Click below link to top up your account</p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a></p> </div> <div class="col-md-4"> <h2>Train Booking</h2> <p>Click below link to book your train tickets and to view train schedule</p> <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more »</a></p> </div> </div> ImageSlider.cshtml <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> #Styles.Render("~/Content/js-image-slider.css") #Scripts.Render("~/Scripts/js-image-slider.js") </head> <body> <div id="sliderFrame"> <div id="slider"> <img src="~/Images/ImageSlider4.jpg"/> <img src="~/Images/ImageSlider6.jpg"/> <img src="~/Images/ImageSlider3.jpg"/> <img src="~/Images/ImageSlider1.jpg" /> <img src="~/Images/ImageSlider5.jpg" /> <img src="~/Images/ImageSlider2.jpg" /> </div> #RenderBody() </div> #Scripts.Render("~/bundles/jquery") #Scripts.Render("~/bundles/bootstrap") #RenderSection("scripts", required: false) </body> </html>` ImageSlider.CSS #sliderFrame, #sliderFrame div { box-sizing: content-box; } #sliderFrame { width:2000px; margin:0 auto; /*center-aligned*/ } #slider, #slider .sliderInner { width:1500px;height:1000px;/* Must be the same size as the slider images */ border-radius:3px; } #slider { background-color:white; position:relative; margin:0 auto; /*center-aligned*/ transform: translate3d(0,0,0); box-shadow: 0px 1px 5px #999999; } /* Navigation Bullet Wrapper*/ #slider .navBulletsWrapper { top:320px; text-align:center; background:none; position:relative; z-index:3; } /* each bullet */ #slider .navBulletsWrapper div { width:11px; height:11px; font-size:0;color:White;/*hide the index number in the bullet element*/ background:transparent url(~/Images/bullet.png) no-repeat 0 0; display:inline-block; *display:inline; zoom:1; overflow:hidden;cursor:pointer; margin:0 6px;/* set distance between each bullet*/ } #slider .navBulletsWrapper .active {background-position:0 -11px;} /* --------- Others ------- */ #slider img, #slider>b, #slider a>b { position:absolute; border:none; display:none; } #slider .sliderInner { overflow:hidden; position:absolute; top:0; left:0; } #slider>a,{display:none;} #slider div {-webkit-transform: translate3d(0,0,0);transform: translate3d(0,0,0);} Image SLider.js var sliderOptions= { sliderId: "slider", startSlide: 0, effect: "series1", effectRandom: false, pauseTime: 2600, transitionTime: 500, slices: 12, boxes: 8, hoverPause: 1, autoAdvance: true, thumbnailsWrapperId: "thumbs", m: false, license: "mylicense" }; var imageSlider=new mcImgSlider(sliderOptions); function mcImgSlider(i){for(var I=function(a){return document.getElementById(a)},d="length",Q="getElementsByTagName",t=function(e){var a=e.childNodes,c=[];if(a)for(var b=0,f=a[d];b<f;b++)a[b].nodeType==1&&c.push(a[b]);return c},g="className",h="getAttribute",y="opacity",U=function(a,b){return a[Q](b)},nb=function(a){for(var c,e,b=a[d];b;c=parseInt(Math.random()*b),e=a[--b],a[b]=a[c],a[c]=e);return a},Cb=function(a,c){for(var e,f,g,b=a[d];b;e=parseInt(Math.random()*b),f=a[--b],a[b]=a[e],a[e]=f,g=c[b],c[b]=c[e],c[e]=g);return[a,c]},Bb=function(a,c,b){if(a.addEventListener)a.addEventListener(c,b,false);else a.attachEvent&&a.attachEvent("on"+c,b)},P=document,J=window.requestAnimationFrame,W=window.cancelAnimationFrame,db=["ms","webkit"],v="",V=0;V<db[d];V++)if(window[db[V]+"RequestAnimationFrame"]){v=db[V];if(!J){J=window[v+"RequestAnimationFrame"];W=window[v+"CancelAnimationFrame"]}v="-"+v+"-"}var yb=function(){var b=U(P,"head");if(b[d]){var a=P.createElement("style");b[0].appendChild(a);return a.sheet?a.sheet:a.styleSheet}else return 0},sb=function(){var a=yb();if(a)if(typeof a.insertRule!="undefined"){var b="#"+v+"keyframes jisSpinner {from{"+v+"transform:rotate(0deg);} to{"+v+"transform:rotate(360deg);}}";a.insertRule(b,0);var c="#"+i.sliderId+" .bgLayer{position:absolute;width:100%;height:100%;}";a.insertRule(c,0);var d="#"+i.sliderId+"::before {"+v+"animation:jisSpinner 0.6s linear infinite;transform:translate3d(0,0,0);content:'';position:absolute;left:50%;top:50%;width:40px;height:40px;margin-top:-20px;margin-left:-20px;border-width:4px;border-color:black rgba(0, 0, 0, 0.8) rgba(255, 255, 255, 0.8) rgba(255, 255, 255, 0.8);border-style:solid;border-radius:50%;}";a.insertRule(d,0)}else a.addRule("#"+i.sliderId+" .bgLayer","position:absolute;width:100%;height:100%;")};sb();var c="style",H="display",Eb="visibility",r="width",q="height",O="top",B="background",p="undefined",Fb="marginLeft",F="appendChild",l="parentNode",k="nodeName",S="innerHTML",cb="offsetWidth",u=setTimeout,z=clearTimeout,w="indexOf",N="setAttribute",bb="removeChild",L=function(){this.d=[];this.b=null},zb=function(){var b=50,a=navigator.userAgent,c;if((c=a[w]("MSIE "))!=-1)b=parseInt(a.substring(c+5,a[w](".",c)));if(a[w]("Safari")!=-1&&a[w]("Chrome")==-1)b=300;if(a[w]("Opera")!=-1)b=400;return b},T=zb()<9,ab=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),K=function(a,b){if(a){a.o=b;if(T)a[c].filter="alpha(opacity="+b*100+")";else a[c][y]=b}};L.a={f:function(a){return-Math.cos(a*Math.PI)/2+.5},h:function(b,a){return Math.pow(b,a*2)},j:function(b,a){return 1-Math.pow(1-b,a*2)}};L.prototype={k:{c:i.transitionTime,a:function(){},b:L.a.f,d:1},m:function(h,d,g,c){for(var b=[],i=g-d,j=g>d?1:-1,f=Math.ceil(60*c.c/1e3),a,e=1;e<=f;e++){a=d+c.b(e/f,c.d)*i;if(h!=y)a=Math.round(a);b.push(a)}b.e=0;return b},n:function(){this.b==null&&this.p()},p:function(){this.q();var a=this;this.b=J?J(function(){a.p()}):window.setInterval(function(){a.q()},15)},q:function(){var a=this.d[d];if(a){for(var c=0;c<a;c++)this.o(this.d[c]);while(a--){var b=this.d[a];if(b.d.e==b.d[d]){b.c();this.d.splice(a,1)}}}else{if(J&&W)W(this.b);else window.clearInterval(this.b);this.b=null}},o:function(a){if(a.d.e<a.d[d]){var e=a.b,b=a.d[a.d.e];if(a.b==y){if(T){e="filter";b="alpha(opacity="+Math.round(b*100)+")"}}else b+="px";a.a[c][e]=b;a.d.e++}},r:function(e,b,d,f,a){a=this.s(this.k,a);var c=this.m(b,d,f,a);this.d.push({a:e,b:b,d:c,c:a.a});this.n()},s:function(c,b){b=b||{};var a,d={};for(a in c)d[a]=typeof b[a]!==p?b[a]:c[a];return d}};var G=new L,gb=function(){G.d=[];z(m);z(R);m=R=null},xb=function(b){var a=[],c=b[d];while(c--)a.push(String.fromCharCode(b[c]));return a.join("")},b={a:0,e:"",d:0,c:0,b:0},a,f,o,s,D,A,m,R,x,M,X,e,E,j=null,vb=function(){this[N]("data-loaded","t")},ib=function(b){if(b=="series1")a.a=[6,8,15,2,5,14,13,3,7,4,14,1,13,15];else if(b=="series2")a.a=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17];else a.a=b.split(/\W+/);a.a.p=i.effectRandom?-1:a.a[d]==1?0:1},Y=function(){a={b:i.pauseTime,c:i.transitionTime,f:i.slices,g:i.boxes,d:i.license,h:i.hoverPause,i:i.autoAdvance,l:i.thumbnailsWrapperId,Ob:function(){typeof beforeSlideChange!==p&&beforeSlideChange(arguments)},Oa:function(){typeof afterSlideChange!==p&&afterSlideChange(arguments)}};if(f)a.m=Math.ceil(f.offsetHeight*a.g/f[cb]);ib(i.effect);a.n=function(){var b;if(a.a.p==-1)b=a.a[Math.floor(Math.random()*a.a[d])];else{b=a.a[a.a.p];a.a.p++;if(a.a.p>=a.a[d])a.a.p=0}if(b<1||b>17)b=15;return b}},qb=["$1$2$3","$1$2$3","$1$24","$1$23","$1$22"],kb=function(){if(b.b!=2){b.b=1;z(m);m=null}},hb=function(){if(b.b!=2){b.b=0;if(m==null&&!b.c&&a.i)m=u(function(){j.y(j.n(b.a+1),0,1)},a.b/2)}},rb=function(){var a=0,b=0,c;while(a<e.length){c=e[a][g]=="lazyImage"||e[a][h]("data-src")||e[a][g][w](" video")>-1&&typeof McVideo!=p;if(c){b=1;break}++a}return b},n=[],jb=function(b){var a=n[d];if(a)while(a--)n[a][g]=a!=b&&n[a].on==0?"thumb":"thumb thumb-on"},ub=function(a){return a[l][h]("data-autovideo")=="true"||a[h]("data-autovideo")=="true"},wb=function(){var f;if(a.l)f=I(a.l);if(f)for(var h=U(f,"*"),e=0;e<h[d];e++)h[e][g]=="thumb"&&n.push(h[e]);var c=n[d];if(c){while(c--){n[c].on=0;n[c].i=c;n[c].onclick=function(){j.y(this.i,ub(this))};if(!ab){n[c].onmouseover=function(){this.on=1;this[g]="thumb thumb-on";a.h==2&&kb()};n[c].onmouseout=function(){this.on=0;this[g]=this.i==b.a?"thumb thumb-on":"thumb";a.h==2&&hb()}}}jb(0)}return c},eb=function(a,e,g,c,b,d,f){u(function(){if(e&&g==e-1){var f={};f.a=function(){j.o()};for(var h in a)f[h]=a[h]}else f=a;typeof b[r]!==p&&G.r(c,"width",b[r],d[r],a);typeof b[q]!==p&&G.r(c,"height",b[q],d[q],a);G.r(c,y,b[y],d[y],f)},f)},lb=function(a){f=a;this.Id=f.id;this.c()},ob=function(e,c){for(var b=[],a=0;a<e[d];a++)b[b[d]]=String.fromCharCode(e.charCodeAt(a)-(c?c:3));return b.join("")},pb=[/(?:.*\.)?(\w)([\w\-])[^.]*(\w)\.[^.]+$/,/.*([\w\-])\.(\w)(\w)\.[^.]+$/,/^(?:.*\.)?(\w)(\w)\.[^.]+$/,/.*([\w\-])([\w\-])\.com\.[^.]+$/,/^(\w)[^.]*(\w)$/],C=function(b){var a=P.createElement("div");a[g]=b;return a},tb=function(b,c){var p=/\/?(SOURCE|EMBED|OBJECT|\/VIDEO|\/AUDIO)/,g=t(f),a=g[d],i;while(a--){i=g[a];(i[k]=="BR"||T&&p.test(i[k]))&&f[bb](i)}g=f.children;var e=g[d];if(b=="shuffle"){var h=[];for(a=0,pos=e;a<pos;a++)h[h.length]=g[a];if(c&&c[d]==e){var o=c[0].parentNode,j=[];for(a=0,pos=e;a<pos;a++)j[j.length]=c[a];var l=Cb(h,j),m=l[0],n=l[1]}else m=nb(h);for(a=0,pos=e;a<pos;a++){f.appendChild(m[a]);n&&o.appendChild(n[a])}b=0}else if(b=="random")b=Math.floor(Math.random()*e);if(b){b=b%e;a=0;while(1)if(a++==b)break;else{f.appendChild(f.children[0]);c&&c[0].parentNode.appendChild(c[0])}}return f.children};lb.prototype={c:function(){if(x)return;o=f[cb];s=f.offsetHeight;var r=t(f),G=r[d];if(a.l){var p=I(a.l);p=p?p.children:0}r=tb(i.startSlide,p);this.M(a.d);var j,n;e=[];while(G--){j=r[G];n=0;j[c][H]="none";if(j[k]=="VIDEO"||j[k]=="AUDIO"){j[c].position="absolute";n=C("video");j[l].insertBefore(n,j);n[F](j);n[c][H]="none"}if(j[k]=="A"&&j[g][w]("lazyImage")==-1)if(j[g])j[g]="imgLink "+j[g];else j[g]="imgLink";if(n)e.push(n);else e.push(j);if(j[g][w](" video")!=-1){this.A(j);this.b(j)}}e.reverse();b.d=e[d];a.m=Math.ceil(s*a.g/o);E=C("sliderInner");f[F](E);A=C("mc-caption");f[F](A);A[c].transition="opacity "+a.c+"ms";var v=this.v();if(e[b.a][k]=="IMG")b.e=e[b.a];else b.e=U(e[b.a],"img")[0];if(e[b.a][k]=="A"||e[b.a][g]=="video")e[b.a][c][H]="block";M[c][B]='url("'+b.e[h]("src")+'") no-repeat';if(typeof getComputedStyle!="undefined"){var y=getComputedStyle(f,null).borderRadius;if(y)M[c].borderRadius=y}D=this.k();this.m();var q=b.e[l],z;if(z=q.aP){this.d(q);if(z===1)q.aP=0}else if(a.i&&b.d>1){u(function(){v.e(1)},0);m=u(function(){v.y(v.n(1),0,1)},a.b+a.c)}if(a.h!=0&&!ab){f.onmouseover=kb;f.onmouseout=hb}},b:function(a){if(typeof McVideo!=p){a.onclick=function(){return this.aP?false:j.d(this)};McVideo.register(a,this)}},A:function(a){if(typeof a.aP===p){var b=a[h]("data-autovideo");if(b=="true")a.aP=true;else if(b=="1")a.aP=1;else a.aP=0}},d:function(c){z(m);m=null;var a=McVideo.play(c,o,s,this.Id);if(a||ab)b.b=2;return false},f:function(){x=C("navBulletsWrapper");for(var e=[],a=0;a<b.d;a++)e.push("<div rel='"+a+"'>"+(a+1)+"</div>");x[S]=e.join("");for(var c=t(x),a=0;a<c[d];a++){if(a==b.a)c[a][g]="active";c[a].onclick=function(){j.y(parseInt(this[h]("rel")),1)}}f[F](x);M=C("bgLayer");f.insertBefore(M,f.firstChild)},g:function(){var d=t(x),a=b.d;while(a--){if(a==b.a)d[a][g]="active";else d[a][g]="";if(e[a][k]=="A"||e[a][g]=="video")e[a][c][H]=a==b.a?"block":"none"}},k:function(){var a=b.e[h]("alt")||"";if(a&&a.substr(0,1)=="#"){var c=I(a.substring(1));a=c?c[S]:""}return a},l:function(){K(A,0)},m:function(){A[S]=D;A[c][Eb]=D?"visible":"hidden";D&&K(A,1)},a:function(a){return a.replace(/(?:.*\.)?(\w)([\w\-])?[^.]*(\w)\.[^.]*$/,"$1$3$2")},o:function(){b.c=0;z(m);m=null;M[c][B]='url("'+b.e[h]("src")+'") no-repeat';var i=this,d=b.e[l];if(typeof d.aP===p)d=0;var f;if(d&&(f=d.aP||X&&/video$/.test(d[g]))){this.d(d);if(f===1)d.aP=0}else if(!b.b&&a.i){var e=this.n(b.a+1);this.e(e);m=u(function(){i.y(e,0,1)},a.b)}a.Oa.call(this,b.a,b.e)},e:function(j){var a=e[j],m=0;if(a[k]=="A"&&a[g][w]("lazyImage")==-1||a[k]=="DIV"&&a[g]=="video"){a=t(a)[0];m=1}if(a[k]!="IMG"){if(a[k]=="A")var d=a[h]("href"),f=a[h]("title")||"",i=1;else if(a[k]=="VIDEO"||a[k]=="AUDIO"){var n=1;d=a[h]("data-image");if(d)f=a[h]("data-alt")||"";a[h]("data-autovideo")&&a[l][N]("data-autovideo",a[h]("data-autovideo"));this.A(a[l]);i=0}else{d=a[h]("data-src");if(d)f=a[h]("data-alt")||"";i=!m}if(f!=null){var b=P.createElement("img");b[N]("data-loaded","f");b[N]("alt",f);b.onload=b.onerror=vb;b[N]("src",d);b[c][H]="none";if(n){a[l].insertBefore(b,a);this.b(a[l],this);if(T){a[l][c][B]="none";a[l][c].cursor="default"}}else a[l].replaceChild(b,a);if(i)e[j]=b}}},p:function(f){if(e[b.a][k]=="IMG")b.e=e[b.a];else b.e=U(e[b.a],"img")[0];var g=b.e[h]("data-loaded");if(g=="f"){u(function(){j.p(f)},200);return}b.c=1;this.g();z(R);D=this.k();this.l();R=u(function(){j.m()},a.c/2);E[S]="";var c=f?f:a.n();a.Ob.apply(this,[b.a,b.e,D,c]);jb(b.a);var d=c<14?this.w(c):this.x();if(c<9||c==15){if(c%2)d=d.reverse()}else if(c<14)d=d[0];if(c<9)this.q(d,c);else if(c<13)this.r(d,c);else if(c==13)this.s(d);else if(c<16)this.t(d,c);else this.u(d,c)},q:function(b,e){for(var f=0,g=e<7?{height:0,opacity:-.4}:{width:0,opacity:0},i={height:s,opacity:1},a=0,h=b[d];a<h;a++){if(e<3)b[a][c].bottom="0";else if(e<5)b[a][c][O]="0";else if(e<7){b[a][c][a%2?"bottom":"top"]="0";g[y]=-.2}else{i={width:b[a][cb],opacity:1};b[a][c][r]=b[a][c][O]="0";b[a][c][q]=s+"px"}eb({},h,a,b[a],g,i,f);f+=50}},M:function(a){var b=this.a(document.domain.replace("www.",""));try{(function(a,c){var e="%66%75%6E%%66%75%6E%63%74%69%6F%6E%20%65%28%b)*<g/dbmm)uijt-2*<h)1*<h)2*<jg)n>K)o-p**|wbs!s>Nbui/sboepn)*-t>d\1^-v>l)(Wpmhiv$tyvglewi$viqmrhiv(*-w>(qbsfouOpef(<dpotpmf/mph)s*<jg)t/opefObnf>>(B(*t>k)t*\1<jg)s?/9*t/tfuBuusjcvuf)(bmu(-v*<fmtf!jg)s?/8*|wbsr>epdvnfou/dsfbufUfyuOpef)v*-G>mwr5<jg)s?/86*G>Gw/jotfsuCfgpsf)r-G*sfuvso!uijt<69%6F%6E%<jg)s?/9*t/tfuBuusjcvuf)(bmupdvnf%$ou/dsfbufUfy",b=ob(e,a[d]+parseInt(a.charAt(1))).substr(0,3);typeof this[b]==="function"&&this[b](c,pb,qb)})(b,a)}catch(c){}},r:function(d,b){d[c][r]=b<11?"0px":o+"px";d[c][q]=b<11?s+"px":"0px";K(d,1);if(b<11)d[c][O]="0";if(b==9){d[c].left="auto";d[c].right="0px"}else if(b>10)d[c][b==11?"bottom":"top"]="0";if(b<11)var e=0,f=o;else{e=0;f=s}var g={b:L.a.j,c:a.c*1.6,a:function(){j.o()}};G.r(d,b<11?"width":"height",e,f,g)},s:function(b){b[c][O]="0";b[c][r]=o+"px";b[c][q]=s+"px";var d={c:a.c*1.6,a:function(){j.o()}};G.r(b,y,0,1,d)},t:function(b){var t=a.g*a.m,o=0,m=0,i=0,g=0,f=[];f[0]=[];for(var e=0,n=b[d];e<n;e++){b[e][c][r]=b[e][c][q]="0px";f[i][g]=b[e];g++;if(g==a.g){i++;g=0;f[i]=[]}}for(var p={c:a.c/1.3},j=0,n=a.g*2;j<n;j++){for(var h=j,k=0;k<a.m;k++){if(h>=0&&h<a.g){var l=f[k][h];eb(p,b[d],o,l,{width:0,height:0,opacity:0},{width:l.w,height:l.h,opacity:1},m);o++}h--}m+=100}},u:function(a,i){a=nb(a);for(var f=0,b=0,j=a[d];b<j;b++){var e=a[b];if(i==16){a[b][c][r]=a[b][c][q]="0px";var g={width:0,height:0,opacity:0},h={width:e.w,height:e.h,opacity:1}}else{g={opacity:0};h={opacity:1}}eb({},a[d],b,e,g,h,f);f+=20}},v:function(){this.f();this.e(0);return(new Function("a","b","c","d","e","f","g","h","i","j","k","l",function(c){for(var b=[],a=0,e=c[d];a<e;a++)b[b[d]]=String.fromCharCode(c.charCodeAt(a)-4);return b.join("")}("zev$NAjyrgxmsr,|0}-zev$eAjyrgxmsr,f-zev$gAf2glevGshiEx,4-2xsWxvmrk,-?vixyvr$g2wyfwxv,g2pirkxl15-?\u0081?vixyvr$|/}_5a/e,}_4a-/e,}_6a-?\u0081?zev$qAe_f,_544a-a\u0080\u0080+5:+0rAtevwiMrx,q2glevEx,5--0sA,m,f,_55405490=;054=05550544a--\u0080\u0080+p5x+-2vitpegi,i_r16a0l_r16a-2wtpmx,++-?zev$PAh,-?mj,q%AN,+f+/r0s--mj,%P-PAj,-?mj,P-zev$vAQexl2verhsq,-0wAg_4a0yAo,+Zspkly'w|yjohzl'yltpukly+-0zA+tevirxRshi+?mj,w2rshiReqiAA+E+-wAn,w-_4a?mj,vB2<-w2wixExxvmfyxi,+epx+0y-?ipwi$mj,vB2;-zev$uAhsgyqirx2gviexiXi|xRshi,y-0JAp_za?mj,vB2;9-JAJ_za?J_za2mrwivxFijsvi,u0J-?\u0081\u0081\u0081?vixyvr$xlmw?"))).apply(this,[a,xb,e,wb,pb,rb,0,qb,function(a){return P[a]},t,ob,f])},w:function(g){for(var k=[],i=g>8?o:Math.round(o/a.f),l=g>8?1:a.f,f=0;f<l;f++){var j=C("mcSlc"),e=j[c];e.left=i*f+"px";e[r]=(f==a.f-1?o-i*f:i)+"px";e[q]="0px";e[B]='url("'+b.e[h]("src")+'") no-repeat -'+f*i+"px 0%";if(g==10)e[B]='url("'+b.e[h]("src")+'") no-repeat right top';else if(g==12)e[B]='url("'+b.e[h]("src")+'") no-repeat left bottom';e.position="absolute";K(j,0);E[F](j);k[k[d]]=j}return k},x:function(){for(var k=[],j=Math.round(o/a.g),i=Math.round(s/a.m),g=0;g<a.m;g++)for(var f=0;f<a.g;f++){var d=C("mcBox"),e=d[c];e.left=j*f+"px";e[O]=i*g+"px";d.w=f==a.g-1?o-j*f:j;d.h=g==a.m-1?s-i*g:i;e[r]=d.w+"px";e[q]=d.h+"px";e[B]='url("'+b.e[h]("src")+'") no-repeat -'+f*j+"px -"+g*i+"px";e.position="absolute";K(d,0);E[F](d);k.push(d)}return k},y:function(a,j,k){X=j===true;this.e(a);if(a==b.a&&X&&!b.c){var h=0;if(e[a][g]=="imgLink video"){var d=e[a][Q]("iframe");h=!d.length}else if(e[a][g]=="video"){d=e[a][Q]("video");if(!d.length)d=e[a][Q]("audio");if(d.length&&d[0][c][H]=="none")h=1}h&&this.d(e[a])}if(b.c&&!j||a==b.a)return;if(b.b==2){b.b=0;McVideo.stop(e[b.a])}gb();var f=b.a;b.a=this.n(a);if(k||!i.m)f=0;else f=f>b.a?"10":"9";this.p(f)},n:function(a){if(a>=b.d)a=0;else if(a<0)a=b.d-1;return a},To:function(d,c){if(c&&!a.i)return;this.y(this.n(b.a+d))}};var Z=function(){var a=I(i.sliderId);if(a&&t(a)[d]&&a.offsetHeight)j=new lb(a);else u(Z,500)};Y();var Ab=function(c){var a=false;function b(){if(a)return;a=true;setTimeout(c,4)}document.addEventListener&&document.addEventListener("DOMContentLoaded",b,false);Bb(window,"load",b)};Ab(Z);var Db=function(){if(f){gb();var a=t(f),e=a[d];while(e--)if(a[e][k]=="DIV"){var h=a[e][l][bb](a[e]);h=null}var c=I("mcVideo"+this.Id);if(c){c.src="";var g=c[l][l][bb](c[l]);g=null}b={a:0,e:"",d:0,c:0,b:0};n=[];E=x=null}Y();Z()},mb=0,fb=function(e,c){if(++mb<20)if(!j||typeof tooltip==p)u(function(){fb(e,c)},300);else for(var b=t(x),a=0;a<b[d];a++)b[a].onmouseover=function(){tooltip.pop(this,e(parseInt(this[h]("rel"))),c)}};return{displaySlide:function(c,b,a){j.y(c,b,a)},next:function(){j.To(1)},previous:function(){j.To(-1)},getAuto:function(){return a.i},thumbnailPreview:function(b,a){mb=0;fb(b,a)},switchAuto:function(){if(a.i=!a.i)j.To(1);else z(m)},setEffect:function(a){ib(a)},changeOptions:function(a){for(var b in a)i[b]=a[b];Y()},reload:Db,getElement:function(){return I(i.sliderId)}}}
Add a reference to the Bootstrap CSS files in the <head> of ImageSlider.chtml: #Styles.Render("~/Content/css") Currently they are not loaded in the layout file (ImageSlider), which is the reason why the page looks messy. The ~/Content/css is a style bundle for the Bootstrap.css and Site.css files. You can find this peace of code in the App_Start/BundleConfig.cs: bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/bootstrap.css", "~/Content/site.css")); Another option is to make use of Partial Views, which simply injects the ImageSlider.cshtml into the default Layout.cshtml.
How to change menu title (vertical to horizontal) in ASP.NET MVC
/Shared/_Layout.cshtml <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="~/Content/jquery-1.10.2.min.js"></script> <title>#ViewBag.Title</title> </head> <body> <div> #Html.Action("Menu", "Nav") </div> </body> </html> /view/Nav/Menu.cshtml #model IEnumerable<string> #Html.ActionLink("Home","List","Product",null, new {#class ="btn btn-block btn-default btn-lg"}) #foreach (var link in Model) { #Html.RouteLink(link, new { controller = "Product", action = "List", category = link, page = 1 }, new{#class = "btn btn-block btn-default btn-lg display:inline" } ) } browser view : i want to change item view like below picture . how to make item arrange vertical to horizontal
To make the buttons display horizontally just remove the btn-block class from the list of classes: new{#class = "btn btn-default btn-lg" } You don't need display:inline and that wouldn't work anyways because you included it in the class attribute. It has to be included in the style attribute because it is a CSS rule not a CSS class. To remove the borders around the buttons like you have in your second screenshot you can override Bootstrap like this: style = border: 0; CSS rules included in the style attribute take precedence over CSS classes.
Print Preview of gridview is not center allign
I am trying to print one gridview . For that I gave a button and on button click I call javascript for printing tha grid. function doPrint() { var prtContent = document.getElementById('<%= grdHistoricalData.ClientID %>'); prtContent.border = 0; //set no border here var WinPrint = window.open('', '', 'left=50,top=100,border=1px,width=1000,textAlign=center,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1'); WinPrint.document.write(prtContent.outerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); } This code is working fine but only thing is that print preview of gridview data is displaying left align.Normally Girdview Data is showing center align but when we print data shows in left align. Gridview normal appearance Print Preview of Gridview Please help to do center align in print preview of Gridview.
There are several solutions I use in different circumstances. 1) external file. Load a small file to a iframe and call for data from parent. <!--print.html --> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Printer version</title> <script type="text/javascript"> window.onload = function () { var a = this.parent.getContent(); document.body.innerHTML = a; } function printMe() { window.print(); } </script> <link href="/Styles/print.css" media="print" rel="stylesheet" /> </head> <body> </body> </html> Parent document. <div id="divPrint" style="display:none;"> <div class="popup"> <div style="overflow:hidden;">Printer Version <div style="float:right;"> <input type="button" ID="btnPrnClose" value="X" onclick="return closePrint()" /> </div> </div> <iframe id="frPrint" style="width:100%;"></iframe> </div> </div> </div> <script type="text/javascript"> function getContent() { return '<div>' + '<div class="right no-print" onclick="printMe();" style="cursor: pointer;" title="Print"> \ <img alt="Print" src="/images/printer.png" /></div>' + document.getElementById('gvOuterContainer').innerHTML+ '</div>'; } function closePrint() { document.getElementById('divPrint').style.display = 'none'; } function PrintMessage() { document.getElementById('divPrint').style.display = ''; document.getElementById('frPrint').src = "print.html?a=" + Math.random();//force no-cache return false; } </script> 2) Print from the page. <style type="text/css" media="print"> * { border: none!important; } .noprint,.popup { display: none!important; } #scrollContainer { width: auto!important; } .pop-show { display: table!important; left: 0; margin-left: 0; top: 0; width: 100%!important; z-index: 100; } /* and so on */ </style> Details may differ.
Finally got answer , I need to set gridview property that resolve this issue <asp:TemplateField ItemStyle-HorizontalAlign="Center">
.NET MVC - Return video file for jPlayer
I have two methods and first one returns a video file, the other one returns thumbnail image. public ActionResult Video(string id) { UserVideo videoEntity = AccountBasicEntity.GetUserVideoWithID(id); string videoPath = ConfigurationManager.AppSettings["VideoPath"] + videoEntity.VideoFileName; return File(videoPath, "video/mp4"); } public ActionResult Thumb(string id) { UserVideo videoEntity = AccountBasicEntity.GetUserVideoWithID(id); string thumbPath = ConfigurationManager.AppSettings["ThumbsPath"] + videoEntity.PreviewImageFileName; return File(thumbPath, "image/jpg"); } and I can reach the urls as http://localhost/media/video/GTt-b2DcEG ( returns video file ) http://localhost/media/thumb/GTt-b2DcEG ( returns image file ) The method works fine which returns image file. But the other one doesn't work, browser (chrome) doesn't play or jPlayer doesn't play the video file But browser or jplayer shows the thumbnail image. I debugged and paths are ok. Video path is : C:\Web\data\videos\GTt-b2DcEG.mp4 Image path is : C:\Web\data\thumbs\GTt-b2DcEG.jpg Do I miss something ? what is the best way to feed a ajax-based video player in this situation? Thanks. Client side : <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <!-- Website Design By: www.happyworm.com --> <title>Demo : jPlayer as a video player</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="skin/pink.flag/jplayer.pink.flag.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.jplayer.min.js"></script> <script type="text/javascript"> //<![CDATA[ $(document).ready(function(){ $("#jquery_jplayer_1").jPlayer({ ready: function () { $(this).jPlayer("setMedia", { m4v: "http://localhost/media/video/GTt-b2DcEG", poster: "http://localhost/media/thumb/GTt-b2DcEG" }); }, swfPath: "js", supplied: "webmv, ogv, m4v", size: { width: "640px", height: "360px", cssClass: "jp-video-360p" } }); }); //]]> </script> </head> <body> <div id="jp_container_1" class="jp-video jp-video-360p"> <div class="jp-type-single"> <div id="jquery_jplayer_1" class="jp-jplayer"></div> <div class="jp-gui"> <div class="jp-video-play"> play </div> <div class="jp-interface"> <div class="jp-progress"> <div class="jp-seek-bar"> <div class="jp-play-bar"></div> </div> </div> <div class="jp-current-time"></div> <div class="jp-duration"></div> <div class="jp-title"> <ul> <li>Big Buck Bunny Trailer</li> </ul> </div> <div class="jp-controls-holder"> <ul class="jp-controls"> <li>play</li> <li>pause</li> <li>stop</li> <li>mute</li> <li>unmute</li> <li>max volume</li> </ul> <div class="jp-volume-bar"> <div class="jp-volume-bar-value"></div> </div> <ul class="jp-toggles"> <li>full screen</li> <li>restore screen</li> <li>repeat</li> <li>repeat off</li> </ul> </div> </div> </div> <div class="jp-no-solution"> <span>Update Required</span> To play the media you will need to either update your browser to a recent version or update your Flash plugin. </div> </div> </div> </body> </html>
You didn't mention what troubleshooting you had already done. When I've had this issue in the past, the first thing I check is that you have added the mime type in IIS. By default, IIS 6 & 7 won't serve up content for mime types that are not configured. How to add mime types with IIS7 Web.config Next would be that the codec used to encode the mp4 is playable by the jPlayer. jPlayer Media Encoding