I am looping through a JSON table using jquerys foreach operator. I am having to reference the the columns by name e.g:
$.each(items, function (index, item) {
if (item.CustomerFname == "Bob") {
alert(item.CustomerFname + " " item.CustomerSname)
}
Whereas I would like to be able to say something like:
[code]....
Ultimately I'm trying to make this function dynamic with respects to the json list I pass in which will of course mean that the column names will change. However I would like to perform the same operations on the columns...
AutoGenerateColumns: Flase/True ( i tried both) If i remove the gvOff.Columns[index].HeaderText portions, GridView works fine, but when i put the gvOff.Columns[0].HeaderText, i get the exceptional error.
, i couldn't solve it. If you need further info, inform me.
EDITED:
Hold on! I commented the HeaderText portion and tested int i = gvOffer.Columns.Count; I found count is 0 eventhough the columns print out with DataBind()... Why? NOTE: AutoColumn in this case is set to true. I guess i will have to edit the column names from DataTable.
I have problem with JSON, MapRoute. If I click on "save" I always get Page / Index Page instead of / SendForm. I dont know why, in javascript it says url: '/ page / sendform'. But the problem is at Global.asax.cs,
But there is still problem at the url, which shows Controller, Action that I dont want to .. I have a url / lang / seo-url /. How can I achieve by clicking on the Save, it should call SendForm method instead of Index ..
public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("page", "{lang}/{url}", new { controller = "Page", action = "Index", lang = "cz", url = UrlParameter.Optional }); routes.MapRoute("Default", "{controller}/{action}/{url}", new { controller = "Page", action = "Index", url = UrlParameter.Optional }); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); ValueProviderFactories.Factories.Add(new JsonValueProviderFactory()); } } Index.aspx <script type="text/javascript"> $(function () { $("#personCreate").click(function () { var person = getPerson(); // poor man's validation if (person == null) { alert("Specify a name please!"); return; } var json = $.toJSON(person); $.ajax({ url: '/page/sendform', type: 'POST', dataType: 'json', data: json, contentType: 'application/json; charset=utf-8', success: function (data) { // get the result and do some magic with it var message = data.Message; $("#resultMessage").html(message); } }); }); }); function getPerson() { var name = "Ruda"; var age = "18"; // poor man's validation return (name == "") ? null : { Name: name, Age: age }; } </script> <input type="submit" value="Save" id="personCreate" /> PageCollector.cs public class PageController : Controller { // // GET: /Page/ public ActionResult Index(string lang, string url) { switch(url) { case "anglictina": return View("~/Views/English/Index.aspx"); case "nemcina": return View("~/Views/German/Index.aspx"); case "prihlaska": return View("~/Views/Application/Index.aspx"); case "galerie": return View("~/Views/Galerie/Index.aspx"); case "kontakt": return View("~/Views/Contact/Index.aspx"); default: return View("~/Views/English/Index.aspx"); } } [HttpPost] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public JsonResult SendForm(string name, string age) { return Json(string.Format("Message: '{0}'", name)); } }
I want to use the DataContractJsonSerializer class. This is contained within theSystem.Runtime.Serialization.Json namespace and the System.ServiceModel.Web dll.or some reason, when I add the using directive for the namespace, Visual Studio says it doesn't recognise the Json namespace in System.Runtime.Serialization.When I try to add the System.ServiceModel dll, nothing happens, which suggests to me it's already referenced. (Because nothing also happens when I try to add a reference to System.Web which is definitely referenced!)
I have a simple class in asp.net mvc that looks like this:
[code]...
It deserializes it so I have to reference everything by index first, because of the list. So if I had a property called "IsValid" I would have to reference it like this "IsValid[0]". I have way too much javascript code to make these changes.How could I deserialize the JsonResponseItem class so I don't need the index reference in there?
On one of our tables, a default clustered index is defined on the primary key by sql server 2005. The table also contains forign key columns and has got over 2 million rows. There are very frequent INSERT, UPDATE and DELETE functions on this table. Recently some of the SELECT queries which primary operate on the forign keys have become very slow (resulting in application timeout). To fix the problem, I defined an index on one of the primary keys which gave me very quick results. I don't know much about indexes.
1. Since I defined a new index (on the forign key) in addition to the existing default index, what kind of index (clustered or non-clustered) have I defined?
2. What performance impact does it have on the rest of the system? Is it going to break something else?
3. I read about fill factor. What is this and how does it effect the system?
4. Is the new index physically going to make any changes?
5. In case I delete this index later on, will the database return to the existing state or it will be a different state from now?
My first method I tried I thought I had solved it. The last 3 tables are populated through a webform. The query I created definitely produces the output above but I had to create 4 more duplicate tables. The solution was a bit shortsighted as users can also delete items from the last table. So when users deleted amounts it did not reflect on the output. I want to know if the above tables can be used to produce the intended output
one juvenile question , i am having a asp.net intranet application which is using jquery, instead of ref jquery to every page, i decided it to put it on the master page inside the script manager scriptReference tag. note not all pages of my application requires jquery, so is it a wise thing to do, or it will affect the performance,
I have a nested master page. A parent master page, a child master page and a content page whose master page is the child master page. I have a reference to jQuery in the parent master page in the head section.<script type="text/javascript" src='<%#ResolveUrl("~/includes/jquery-1.4.2.min.js") %>' ></script> & Page.Header.DataBind(); in the OnLoad event.
I am using jQuery in all the pages including the master pages. However I am getting "Error: $().ready is not a function" in the content page. If I include jQuery reference in the content page it works. Question: If the reference to jQuery is in the master page head section, why aren't the content pages able to use jQuery? When I do view source, the script tag with jQuery is there and it works. The master pages and content page are merged during rendering and sent to the browser as a single html page so I am not sure when master pages are used, jQuery references break.
UPDATE:
When I changed '$.ready(function()' to 'jQuery(document).ready(function($)' it worked! I am not loading any other javascript libraries and I am not using MS Ajax.
I am having with the a full text index I am developing for a product catalog. It does all work to a degree I am just seeing some strange things happening.
From the database side I have a Products table that is being indexed on both the PartNumber and Description columns because I would like the users to be able to search either or using the search function.
Problem 1:
whenever I use multiple words in the search I don't always get the results I am looking for, this happens most notably when I am attempting to say put in a full part number (which for in this case would look like "I 10-9.2")
Problem 2:
I am not 100% sure that this is the most efficient way of completing what I am attempting to accomplish here since I have 2 columns that I need to perform the search on
Here is an excerpt from the click even when the user clicks the search button on the page:
[Code]....
And here is the search functions called from the click event to firstly check if there are any results and the second to display the results in a custom gridview:
I want to filter grid view, drop down list should select the column and text box will filter the column. like ID NAME Phone Designation fields in gridview.i will select Designation in dropdown and type programmer in text box .so it should filter programmers from the gridview...
I want to do like below:I have three dropdownlist:
- test - test1 - test2 and i have two textbox - txtname - txtsex
when i click on test dropdown list i want to diplay data in test1 dropdownlist and display in txtname and txtsex too, how can i do by using mvc json and jquery ?
I was wondering to use JQuery with the light wieghted Json and it was a wonderful experience and a very positive performance boosting or the entire project.
I was hoping that anyone else had the same experience with asp.net project geared up with Jquery and Json?
I'm creating an inbox system for my website which allows basic communication between users. I'm fetching the results with jquery calling a webservice. Then I'm using a jquery template engine to render the results to the screen. So far this all works good. but now I want to add some click functions on certain parts of inbox messages. For example I want the title of the message to be clickable so it will expand/collapse the fulltext which is hidden in a div beneath it.
But I can't seem to use the jquery selectors on this dynamic json result. It works when I put the function in the href tag itself but I don't really want to. I also tried adding the function after the success function but no luck either. Is it possible at all to use selectors with a template engine? I hope I made myself clear otherwise feel free to ask more information.
I am new to ASP.NET MVC 2. In my project, there are two selects: one that contains a list of countries and another that should contain the states/provinces/etc for the country selected in the previous select.
Is there any possibility to create a cascading select without using any client scripting?
.I am using VS2010 Ultimate in an out of the box HelloWorld MVC2 ProjectI am using JQuery 1.4.1I have the following code in my View:
function TestStringArray() { var stringArray = new Array(); stringArray[0] = "item1";
[code]...
Forgetting my controller actually needs to return a Json result (I have a break on the return View() line), the values parameter is null. When I pass in a single string (change the type from List<String> to String in the controller, pass in a single string value from the View), it works fine. Looking at Fiddler, the array is passing the multiple values.I did some research and people are suggesting JSON.Stringify ion the JSON2 library, the JSON.NEt library, etc... Do I really need extra libraries? Microsoft didn't think of this scenario for out of the box? I assume the problem is any kind of complex type.