w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Why does Visual Studio's MVC template set ViewBag.Title in views rather than in the corresponding controllers?
its on the coder to decice what action method return what views.. so your controller OR Action method might just return a JSON object or an HTTPResponseCode in that case there is no point setting the title inside the controller or action method.. its ultimately is a presentation thing as you might also not want to display to say Create on a view that creates your entity instead you might wanna say Create which now depends upon the action method and the controller.

Categories : C#

How to access properties to an object at a specific index in a Viewbag, out of a foreach?
You should try and avoid getting into the messiness of getting razor variables inline with your javascript. Also, try to shy away from using ViewBag wherever possible. I would approach this by having a method on one of your controllers which takes a Contact string as a parameter, and accesses your database and returns a list of the variables you want. Then, add an event handler in javascript to your value change event of your dropdown box, and fire off an Ajax call to your controller method. This would then access your data storage, and return the values, which would then be fed down to your JS via ajax. You could then populate your textboxes at your leisure.

Categories : C#

How do I set the default title view for my navigation controllers?
You could try adding a subview (UITextField) to your navigation bar: UITextField *titleField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 100.0, 60.0)]; titleField.text = @"a title"; titleField.center = self.navigationController.navigationBar.center; [self.navigationController.navigationBar addSubview:titleField];

Categories : Iphone

slidify layouts: title-only, title-and-body, title-and-two-cols, title caption, and blank
Slide layouts are mustache templates that can make use of objects returned by the parser. You can find a list of objects returned by the parser here. Coming to the question raised, here is how one would go about building the layouts for the slides. Title Only <slide class="segue nobackground {{ slide.class }}" id="{{ slide.id }}"> <hgroup> {{{ slide.header }}} </hgroup> </slide> The two column layout inherits from the parent layout, and the column widths are configurable. Two Columns --- layout: slide replace: slide.content --- {{{ slide.content }}} <div class='left' style='float:left;width:{{{ slide.left.w }}}'> {{{ slide.left.html }}} </div> <div class='right' style='float:right;width:{{{ slide.right.w }}}'> {{{ slide.right

Categories : R

The story with Index Controllers, Views, Templates?
Ok, I think it can be chalked up to a newbie question. The relationship between these two controllers/views/templates becomes far more clear when I put an {{outlet}} into the /password_reset template. Then I can see that the password_reset/index shows up as the outlet. The index, in effect, becomes the default outlet when a sub-route is not defined. Pretty basic but somehow I didn't get it until I bumped into a wall or two.

Categories : Ember Js

Pandas index column title or name
You can just get/set the index via its name property In [7]: df.index.name Out[7]: 'Index Title' In [8]: df.index.name = 'foo' In [9]: df.index.name Out[9]: 'foo' In [10]: df Out[10]: Column 1 foo Apples 1 Oranges 2 Puppies 3 Ducks 4

Categories : Python

binding controllers from other controllers not working in rc8
Is this a bug, or do I need to change my strategy of binding controllers to attributes using the needs attribute. No it's not a bug, the use of somePropertyBinding was quietly deprecated in favor of computed properties. For reference please see the comment by Peter Wagenet here: https://github.com/emberjs/ember.js/issues/1164#issuecomment-23200023 And as for the new strategy you should use Ember.computed.alias. Example: App.JobsTableController = App.TableController.extend needs: ['jobsTableColumns'] columns: Ember.computed.alias('controllers.jobsTableColumns') This way you don't need the extra work in the JobsTableRoute setupController hook. Hope it helps.

Categories : Ember Js

Javascript Slider title replace html for title just working on 1st item
I found a couple of issues with your script, but first you have invalid markup in your page since you have multiple <div> elements with the same ids of tbtit and tbdescp. Id attributes should be unique in a HTML page so should change those to classes instead. Now in your script you need to change the part where you retrieve the values of the title and the description of the image that is hovered to reference the sibling elements: //THIS var tbtit = $("#tbtit").html(); var tbdesc = $("#tbdescp").html(); //SHOULD NOW BE THIS var tbtit = $(this).siblings('.tbtit').text(); var tbdesc = $(this).siblings('.tbdescp').text(); Finally when you update the text for your main image you want to set the content for your <h4> and <p> tags and not replace them completely, so use .t

Categories : Javascript

dynamically apply title of html document into the title fields of images
var title = document.title; $('.sth').attr('title',title); Edit, but I don't really see the point of doing this. The title of the site has little to do with the images, if it's added to all of them, what is the point anyways?

Categories : PHP

(javascript / google scripts) How to get the title of a page encoded with iso-8859-1 so that the title will display correctly in my utf-8 website?
Where are you displaying the content is more important. If you are writing it to a spreadsheet, then you have to change the settings of the spreadsheet to the correct language (French). In addition, you can use the advanced parameters to specify what charset the original content is in. For example, var result = UrlFetchApp.fetch( url , {contentType : 'text/html; charset=utf-8'}); var wholePage = result.getContentText(); var scrap = wholePage.match( /<title>(.*?)</title>/ ); var title = scrap[1];

Categories : Javascript

Responsive menu with title: have a resizing title that takes up all available space
Unfortunately, this is not possible with CSS only — not if you want to work with IE8. You have to calculate the available space to fill the divs within, and the calc()'s function just work on modern browsers. I created two topics to search a responsive solution to percentage containers, and the results are here and here. The JavaScript's final solution is this: /** Centralize the main container **/ function calculateMainContainerWidth() { $realWidth = $(".main-container").width() - $(".right").outerWidth(), $containerContent = $(".left"); $containerContent.css("width", $realWidth); }; $(window).on("resize", function() { calculateMainContainerWidth(); }); calculateMainContainerWidth(); Also available in FiddleJS. I hope it helps.

Categories : Jquery

ViewBag In ASP.NET MVC
That's a dirty code, dude! Take a look at @Html.ValidationSummary and @Html.ValidationMessageFor Well, some codes here to clarify stuff: [HttpPost] public ActionResult MyAction(ModelClass inputModel) { if (ModelState.IsValid) { //for example we're trying to save our data to db var result = _myRepository.saveStuff(inputModel); if (result) return RedirectToAction("someAction"); ModelState.AddModelError(string.Empty, "An error occured, check input data"); } return View(inputModel); } Also you can specify key (which is your model field name) instead of string.Empty -> so you'l see error message under specified field (as default), but basically what people do is exluding property errors from validation s

Categories : Asp Net Mvc

View Pager Title Strip to show one title Only
get pagerTitleStripe (pagerTitleStripe=(PagerTitleStrip) findViewById(R.id.pager_title_strip);) set alpha to 0 in secondary views (pagerTitleStripe.setNonPrimaryAlpha(0);) y listo!

Categories : Android

RenderPartial and ViewBag
You can use: @Html.Partial(viewName) In partial viewbag from main view will be accessible. Ok. If you need render html from partial view to pdf you can use this code: @{ var htmlString = Html.Partial(viewName); var pdfData = PdfComposerClass.CreatePdfStaticMethod(htmlString); }

Categories : Asp Net Mvc

ViewBag and Formatting
ViewBag and ViewData are only valid for the current request, they wont survive if you do a redirect RedirectToAction. Use TempData instead. Check the following: ViewBag, ViewData and TempData If you want your URLs to be /Manage/Password and /Manage/EmailAddress, you dont need to add a new MapRoute, the default one will work. Just use ManageController for you controller class name and "Password" and "EmailAddress" for your function names: class ManageController { public ActionResult Password(...) {

Categories : C#

Template for ViewBag
Actuall, you can't. The contents of the ViewBag is Dynamically Resolved at Runtime. As opposed to Model properties. You can only use Templates for properties of a Model. The only other option would be to add it to your model. The reason behind this is that, Your model (or View Model to be precise) ought to have everything that your view needs to display data. The ViewBag was intended to add some flexibility for data that doesn't necessarily need to be in your model like the contents of a DropDownList. Therefore, if you need to display content from the ViewBag like properties in your page, then you should consider promoting that property to your model. Alternatively, you could use Partial Views. like so @Html.Partial("_MyTemplate",ViewBag.Data)

Categories : C#

convert ViewBag to routeValues
You could pass RouteValueDictionary directly into the ViewBag. Like so... @Html.ActionLink("LinkText", "ActionName", new RouteValueDictionary(ViewBag.RouteValues)) Then in your Controller you will have... ViewBag.RouteValues = new RouteValueDictionary( new { Page = 5, IntVal = 5, StrVal = "Hello" });

Categories : Asp Net Mvc

How does ViewBag in ASP.NET MVC work behind the scenes?
ViewBag is a property of ControllerBase, which all controllers must inherit from. It's a dynamic object, that's why you can add new properties to it without getting compile time errors. It's not static, it's a member of the object. During the request lifetime, the controller instance is created and disposed, so you won't have "concurrency" problems, like overwriting the value. The View (and its variants) method is not static as well, and this is how the view receives the ViewBag values: during the process of rendering the view, the controller instance has its ViewBag instance as well.

Categories : C#

MVC Passing ViewBag value from another controller
ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0. Basically it is a wrapper around the ViewData and also used to pass data from controller to corresponding view. It’s life also lies only during the current request. If redirection occurs then it’s value becomes null. It doesn’t required typecasting for complex data type. Below is a summary table which shows different mechanism of persistence. Credit:CodeProjectArticle

Categories : Asp Net Mvc

Check if ViewBag value is null
Actually In controller you have set the ViewBag.Ent as the dynamic expression but in the view page you are adding "ViewBag.Ent.MyDate" for accessing it, So this wont work.Use your code like this Script $(document).ready(function () { if ("@ViewBag.Ent" != null) { alert("@ViewBag.Ent"); } });

Categories : Javascript

Difference between window.title and document.title
The window object doesn't have a title property. http://www.w3schools.com/jsref/obj_window.asp Hope this helps! Cheers, LC

Categories : Javascript

Page Title and Site Title Configuration DNN 7
The default behavior is automatic if you leave the "Page Title" setting blank within the settings for the individual page. To accomplish what you desire you will need to customize the settings on a page-by-page basis.

Categories : Asp Net

Enumerable objects in ViewBag in MVC4
Don't use a viewbag for something like this - instead strongly bind your view to a model. Only use a view bag if you have something really small to pass.. anything complex you should always use a strongly typed view model, you get intellisence and its must cleaner for unit testing View Model: Public class MyViewModel { public List<F> MyListOfFObjects { get; set; } } Now when you create your view you can bind it to this view model in the popup or if you don't want to recreate it simply add a reference to it at the top of your view like so: @model <your project>.<folder view model is in>.<view model name> for example @model AdventureWorks.Models.EmployeeViewModel. In your controller you simply create this view model and pass it to your view such as: pu

Categories : Asp Net Mvc

In my hybrid project i can not create a viewbag
you have missed some Web.config int the view folder /Views/Web.Config <configuration> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> // <-- this line and contents are important <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> try this and let me know

Categories : Asp Net

How can I access viewbag in a class library?
Have you tried passing the Viewbag into the Method? Where are you using the class library in your MVC project? Update: You are calling the class library from the controller Here is an example if your viewbag is for ice cream and your class library calculates price. In controller and viewbag is set to chocolate. Call class library and pass Viewbag.Icecream.ToString() Return from class libray "$1.50" Pass the returned data to the view

Categories : Asp Net Mvc

How to pass data from razor into a viewbag
There are some ways to do this. One of them is using Formcollection <input type="input" name="myData[1]"/> <input type="input" name="myData[2]"/> and on controller you can do: [httpPost] public ActionResult myController(FormCollection form) { var myData1 = form["myData[1]"]; var myData2 = form["myData[2]"]; }

Categories : Asp Net Mvc

Evaluate value from web.config file via ViewBag
You have more possibilities to better resolve this issue, maybe in a more controlled way. You can maybe create an ActionFilter and decorate the main controller (or other controllers that you need this property) to read the application key (like WebConfigurationManager.AppSettings["PFUserName"].ToString() ) That way you have more control and behavior setting over the ViewBag. Another solution, is if you have a baseController, you can set a property to read this app Key, although only if you need in your entire application. OOrrr, if you need it only on one action, then the best is to simplify and set the ViewBag in there.

Categories : C#

Assign ViewBag value to input checkbox?
I recommend using this, assuming you are using Razor: @Html.CheckBox("chkSolicitation", (bool)ViewBag.Solicitation) If you are not using Razor, use this: <%: Html.CheckBox("chkSolicitation", (bool)ViewData["Solicitation"]) %>

Categories : Asp Net Mvc

Is it possible to serialize or save viewbag state?
The ViewBag is a DynamicViewDataDictionary, which inherits DynamicObject. Getting the keys is straightforward using "GetDynamicMemberNames", but getting the values is slightly more verbose. The following converts the ViewBag to a dictionary (shamelessly plagiarized borrowed from Aaronaught's answer here): var values = new Dictionary<string, object>(); IEnumerable<string> keys = ViewBag.GetDynamicMemberNames(); foreach (string key in keys) { var binder = Microsoft.CSharp.RuntimeBinder.Binder.GetMember( CSharpBinderFlags.None, key, ViewBag.GetType(), new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }); var callsite = CallSite<Func<CallSite, object, object>>.Create(binder); var val = callsite.Target(callsite,

Categories : C#

ViewBag in static method of controller
ViewBag is a property of your controller (more specifically of ControllerBase), and since a static method has no knowledge of a class instance, you can't access it. You could pass the controller instance to the method if you want to use a static method or even make it an extension method, but depending on your problem, this solution could be sub-optimal. You may be able to get a better answer if you add more details to your question. Public ActionResult Index() { this.loadViewBag(); return View(); } public static void loadViewBag(this ControllerBase target) { target.ViewBag.aaa = "something"; }

Categories : Asp Net Mvc

Dynamically insert class in < li > with ViewBag
here you go: <ul> <li class="@(ViewBag.ActivePage == "Dashboard" ? "active" : "" )">...</li> <li class="@(ViewBag.ActivePage == "Calendar" ? "active" : "" )">...</li> <li class="@(ViewBag.ActivePage == "Serv" ? "active" : "" )">...</li> <li class="@(ViewBag.ActivePage == "Prod" ? "active" : "" )">...</li> </ul>

Categories : Asp Net

check member existence in Mvc ViewBag
You can you use it; @if (string.IsNullOrEmpty(ViewBag.Utente.Ruolo.SysAdmin)) { } But if you want to check your users are confirmed or not, I think it is not a good way..

Categories : Asp Net Mvc

ASP.NET MVC ViewBag's relation to client-side validation
You should never give the same name to the ViewBag variable and your properties from your model. All these values in the end reside in FormCollection and when two of them have the same name/key they override each other and you get some really funky behavior. I'm not sure what the issue is precisely with your scenario (usually people have a ViewModel of some sort) but consider the following scenario: public class Product { public int ProductId { get; set; } public string ProductName { get; set; } } if this is your model and in your controller action you do something like: public ActionResult EditProduct(int id) { var model = ProductDomainLogic.GetProduct(id); ViewBag.ProductName = "Whatever"; return View(model); } you just gave yourself a serious headache because there

Categories : Asp Net Mvc

Using Ajax to update ViewBag data ASP.NET MVC4
you can't repopulate the ViewBag itself. I don't know if this is the best way but I would have done it the following way: HTML: <div> <select id="city"> options </select> </div> <div id="district-select"> <select> </select> </div> JS: $("#city").change(function() { var id = $(this).val(); $.ajax({ type: "GET", url:"/CONTROLLER/GetDistrictsByCity", data: {cityId: id}, success: function(data) { $("#district-select").html(data); } }); }); ACTION: public ActionResult GetDistrictsByCity(Guid cityId){ //GET Districts that is linked to the cityId return PartialView("_DistrictsByCity", model); } and then in the view "_DistrictsByCity" all you create is the dropdownlist.

Categories : Asp Net Mvc

syntax of using Viewbag in aspx view engine?
It is complaining because ValidationSummary has no single parameter overload that takes a parameter of type dynamic; that is what ViewBag properties are. Cast the property to a string. <%= Html.ValidationSummary((string)ViewBag.ValidationSummary)%>

Categories : C#

asp.net mvc reading ViewBag generic list via javascript
One of the easiest ways to pass data back and forth from your ASP.NET code to your JS layer, is to serialize your objects and then render the serialization into the View as a JS object. Here's an example: // helper extension method public static string ToJSON(this object o) { var oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); return oSerializer.Serialize(o); } Inside your controller: Viewbag.Foo = myObj.ToJSON(); Then, inside your View, you just spit out the serialized obj as literal JavaScript: var json = @Html.Raw(Viewbag.Foo); // mix of Razor and JS here! When you run it, if you view source, you'll see something like this in that section of the View: var json = {"prop1":true, "arrayItems":[{ "prop1": "dog" }, { "prop": "car" }]}

Categories : Javascript

Adding a viewbag (in place of actionname) in ActionLink
You need to cast ViewBag.Link into string @Html.ActionLink("click me!", (string)ViewBag.Link, "Home", null, new {@class = "button-big" }) there is no overload as below see msdn docs, which you are using @Html.ActionLink Method (HtmlHelper, String, String, String, Object) Thus use @Html.ActionLink Method (HtmlHelper, String, String, String, Object, Object)

Categories : Asp Net

pass single value from viewbag in mvc4 to javascript
If your javascript is inline, you can do: var data = new google.visualization.DataTable(); data.addColumn('string', 'Topping'); data.addColumn('number', 'Slices'); data.addRows([ ['I', <%: ViewBag.QueryI %>], ['D', <%: ViewBag.QueryD %>], ['S', <%: ViewBag.QueryS %>], ['Sh', <%: ViewBag.QuerySh %>], ]); However I would recommend storing the javascript in a seperate .js file, and applying the values to relevant HTML data attributes and calling them from there. <div class="google_data_table" data-queryi="<%: ViewBag.QueryI %>" data-queryd="<%: ViewBag.QueryD %>" data-querys="<%: ViewBag.QueryS %>" data-querysh="<%: ViewBag.QuerySh %>"> //Google data table here </div> Then using raw javascript, or a js library (I've u

Categories : Javascript

Using 'Html.EditorFor' to pass data to controller using ViewBag
@Html.EditorFor requires a strongly-typed model. It cannot be used with data from the ViewBag. If you must use ViewBag to pass data to the view, use @Html.TextFor(...) instead to manually setup the input field. However, I recommend you use a strongly-typed model. Edit: Model: public class MyModel { public TABLE_CODES Keys { get; set; } } Controller: var model = new MyModel(); model.Keys = new TABLE_CODES(); return View(model); View: @model MvcApplication1.MyModel .... @Html.EditorFor(m => m.Keys)

Categories : Asp Net

MVC3 Razor ViewBag.Model not making into the Page
You need to simply return View(theModel). If you don't pass the model into View() it doesn't know what to do. However, I'm confused about the code you have listed, you seem to be trying to put the model into the ViewBag? The ViewBag shouldn't contain the model. I think the code you want is: public virtual ActionResult Edit(long id) { var _news = _newsRepository.GetNewsById(id); var model = AutoMapper.Mapper.Map<News, NewsModel>(_news); model.CurrentNewsImageFile = ConfigSettings.HostDomainName + ConfigSettings.NewsImageBasePath + _news.image_file; return View(model); }

Categories : Asp Net Mvc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.