w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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#

Rendering Layout in the right time
I would suggest using an "on show" listener on the layout to render the layout's views. You can see an implementation of that solution here :https://github.com/davidsulc/marionette-gentle-introduction/blob/master/assets/js/apps/contacts/list/list_controller.js#L43 Notice that we create the layout instance, as well as the views it will display. Then, when the layout is shown, we have the layout's regions display the proper views.

Categories : Backbone Js

RoR: rendering devise login into application layout
Whats the name you have used for sign in page. if its as - "new.html.erb", then rename it to "_new.html.erb". then, <%= render "devise/sessions/new" %> will work. for second issue, that will be coming again after above thing. NameError in Users#show undefined local variable or method `resource' as can see, no variable can be found in 'show' action, you need to define a variable. From which, form will get some data. go through, forms and flow for rails app, once again.

Categories : Ruby On Rails

Rails link_to_add_fields with jquery Mobile not rendering the layout
Where did link_to_add_fields come from? It's not standard rails or jquery, IIRC. It sounds like something out of a railscast, which isn't necessarily designed with jquery_mobile in mind. edit You have to notify jquery mobile of the changes so it can repaint the page. See http://jquerymobile.com/demos/1.2.0/docs/pages/page-scripting.html in the section "Enhancing new markup" Enhancing new markup The page plugin dispatches a pageInit event, which most widgets use to auto-initialize themselves. As long as a widget plugin script is referenced, it will automatically enhance any instances of the widgets it finds on the page. However, if you generate new markup client-side or load in content via Ajax and inject it into a page, you can trigger the create event to handle the auto-initializat

Categories : Jquery

Zend Framework 2 : Layout only rendering on index action
Ok I resolved my problem, so it was really dummy (yes I am) error: I've put a link in to cv.phtml: <a href='$this.basePath()'>my link</a> So each time I tried to render both layout + view, the view script thrown an exception : "$this.basePath() is an unknown function" Me yesterday : "Whaaaaat ?! And so why ? I used it into index.phtml !" Me today : "What a mess ! PHP calls object methods using a ->, not a '.'. So the view script cv.phtml doesn't have any error left and it works as it should with my layout. Thanks to all for your replies, and to Jurian Sluiman that confirmed me that there was probably an error into my cv.phtml.

Categories : PHP

ServiceStack Razor Engine not rendering Layout (_Layout.cshtml)
Seems Visual Studio did not pack all the views correctly in the publish package. A little fiddling with the build actions and it worked fine. Some of the views had build action "None", while others had "Content". (So much hassle for so little)

Categories : Iis

Magento overriding a layout file causes the overriden layout to duplicate
Well I found the answer: My REAL issue is that I did not know enough about references and blocks. My TECHNICAL issue is that I was referencing one block and then creating a new block with a different name. The "Left" block also contained a version of the navigation bar. This was causing the duplicate menus. My final code looks like this: <affiliateplus_default> <block type="affiliateplus/account_navigation" before="-" name="account_navigator" template="affiliateplus/navigation.phtml"> <action method="setNavigationTitle"> <title helper="affiliateplus/account/getNavigationLabel" /> </action> <action method="addLink" translate="label" module="affiliateplus"> <name>b

Categories : Xml

Resource.Layout.filename is returning the wrong layout file
This appeared to be a bug in MonoDroid, here is the link to the bug in Xamarin bugzilla This is caused by the Resource.Designer.cs in the MFA library project has a different ID (int) values than what the main project has in its Resource.Designer.cs file. I have worked out a workaround for it. In my mainApp I manually call mainApp.Resources.UpdateIdValues(); and that would update the Resources id values in the other MFA library projects Xamarin said that this bug was resolved in 4.6.4. I have not tested this fix though

Categories : Android

Load an existing xml layout file in another xml layout file
At runtime you can use an inflater, for instance: Inflater inflater = LayoutInflater.from(this); View view = inflater.inflate(R.layout.intro_step1_activity, null); then you can add this view to the current view hierarchy. At compile time you can use the include tag for the xml <include layout="@layout/intro_step1_activity"/>

Categories : Android

How to make a .xml layout file the layout of a custom View?
You need to inflate the .xml layout you created. Do it like this: public class CustomLinearLayout extends LinearLayout { // you need this constructor when you use the customview from code public CustomLinearLayout (Context context) { super(context); addView(LayoutInflater.from(context).inflate(R.layout.yourlayout, null)); } // you need this constructor when the customview is used from .xml public CustomLinearLayout (Context context, AttributeSet attrs) { super(context, attrs); addView(LayoutInflater.from(context).inflate(R.layout.yourlayout, null)); } }

Categories : Android

screen support multiple devices using layout-large,layout-normal and layout-xlarge folders
Here there is the official description of how support all the screen size. And as described the layout folders are: res/layout/my_layout.xml // layout for normal screen size ("default") res/layout-small/my_layout.xml // layout for small screen size res/layout-large/my_layout.xml // layout for large screen size res/layout-xlarge/my_layout.xml So layout and layout-normal folder are the same, but in the new Android API there isn't no more the layout-normal folder, but only layout folder. Also you have to know if there isn't the specific layout of the screen size in witch the app is running, by default the app takes the "default" layout. EDIT You can have different screen resolutions in the same folder, as you can learn from this images: If you want a more spec

Categories : Android

Downloading XML file instead of rendering using Builder
Have you tried something like this respond_to do |format| format.html format.xml { send_file :filename => 'mydoc.xml', :type=>"application/xml", :disposition => 'attachment' } end

Categories : Ruby On Rails

rendering html from cs file to cshtml
You should use Html.Raw method in your view: @Html.Raw(class1.createhtml())

Categories : C#

Rendering openGL texture: Class function causes rendering to fail
I did see your mistake within one second. So you didn't waste anyone's time (except your own ;) ). Anyway doing it like this: void CControl::RenderChildren() { for( int i = 0; i < Children.size(); i++ ) { Children[i]->X(Children[i]->X()+_X); //offset child _X with parent's _X Children[i]->Y(Children[i]->Y()+_Y); //offset child _Y with parent's _Y Children[i]->OnRender(); Children[i]->X(Children[i]->X()-_X); Children[i]->Y(Children[i]->Y()-_Y); } } is not optimal. In your case you're using integers where you're experiencing any problems. But say at one point you decide to use floats: The problem is, that every operation happening on floating point numbers creates round off error. Doing it iteratively (li

Categories : C++

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

NVD3 Sparkline not rendering correctly from CSV file
The problem was that the y values were strings. I changed monthlyData.push({x: data[i].Month, y: data[i].Data}); to monthlyData.push({x: data[i].Month, y: +data[i].Data}); so that the y value becomes a number. Here's the updated version.

Categories : Javascript

Rendering mustache template stored in file
You can't access server-side file in javascript directly, but you can use an alternative way to store template on the server side. You can store the template in app/views/projects/project.mustache for example. In your project.mustache, you can write: <script type="text/html" id="project_template"> ... </script> In your view, you can use: <%= render :file => 'projects/project.mustache' %> And use javascript as same as before. $('#target').append(Mustache.to_html($('#project_template').html(), json-data)); I think it isn't perfect, but it should work :)

Categories : Javascript

How to insert string into an erb file for rendering in rails 3.2?
Seems like a job for partials. # app/views/some_folder/_my_erb_partial <%= t(whatever) %> ... <table class="table table-striped"> <%= render 'some_folder/my_erb_partial' %> </table> Update. If you need to store ERB templates in your database and render them in real time, take a look at render erb from database into view problem please help! However, I don't know if this is necessarily your best option, as it could lead to security issues and other issues (namely, if you change code, your templates stored in the database would likely break). In most cases, it would be best just to make a new model for whatever you need to do, and do it the Rails way (with partials).

Categories : Ruby On Rails

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#

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

Rendering on specific pages through application.html.erb file?
I might suggest to put the search box not in the application.html page but maybe in the separate html pages that you want it to render on. You could make the search a partial so that you could access it from the other pages with just one line of code.

Categories : Ruby On Rails

How to escape while rendering a js.coffee file in response to an action
I solved the problem by changing the double quotes in the js.coffee file, but I'm still not sure its a bug. Hopefully this will help someone else! Changed: $('my_container').append("<%= j render(:partial => 'my_partial') %>") to $('my_container').append('<%= j render(:partial => 'my_partial') %>')

Categories : Ruby On Rails

Convert image file to base64 with rendering in a view
Perhaps another aproach could be to include a timestamp parameter with the current datetime to avoid caching. This technique is used sometimes to prevent caching webpages in browser, and perhaps can be used here. Just an idea.

Categories : C#

hosted kmz file stopped rendering on google maps
With KmlLayer I get a status: FETCH_ERROR, on your server, not sure why: http://www.geocodezip.com/v3_GoogleEx_layer-kml_linktoB.html?filename=http://www.la2ba.com/interface/LA2BA.kmz It works if I put a local copy on my server: http://www.geocodezip.com/v3_GoogleEx_layer-kml_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/LA2BA.kmz and it seems to work OK with geoxml3 (the local copy): http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmztest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/LA2BA.kmz

Categories : Google Maps

Capture pygraphviz image rendering without saving to a file?
According to the sources if you call draw method of AGraph object while path parameter is omitted (or set to None) it will return data instead saving to a file. Do not forget to specify format paramater.

Categories : Python

Jinja2 template rendering multiple or single file
There is not any performance loss when using template inheritance,You will have to use it in any projects because of Re-usability.But that does not mean you can indefinitely inherit because it will have file read overheads.

Categories : Python

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

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#

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

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

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

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

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

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

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

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

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

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#



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