Monday, September 7, 2009

ExtJS Grid does not work with asp.net mvc

ExtJS Grid does not work with asp.net mvc

Hello, I still need your help, and more specifically the implementation of the ExtJS grid.
I can not make it work.
I have a View that makes a search with more parameters, then the controller will have the action research that when loading the page I set the controls of the latter, and then I post the action through which I search. This is the code:

[Authorize (Roles = "OP_Bollettino")]
[AcceptVerbs (HttpVerbs.Get)]
Search public ActionResult ()
(



Viewdata [ "checksurname"] = "false";
abilitatosur.Add ( "Disabled" "Disabled");
Viewdata [ "abilitasur"] = abilitatosur;
Viewdata [ "checkcf"] = "false";
abilitatocf.Add ( "Disabled" "Disabled");
Viewdata [ "abilitacf"] = abilitatocf;
abilitatocaus.Add ( "Disabled" "Disabled");
Viewdata [ "checkcausale"] = "false";
Viewdata [ "abilitacaus"] = abilitatocaus;
Viewdata [ "selection"] = "Select";
string EndDate = null;
string StartDate = null;
DataFire DateTime.Now.Date.AddDays = (-30);
EndDate = dataf.ToShortDateString ();
data = DateTime.Now.Date;
StartDate = datai.ToShortDateString ();
Viewdata [ "StartDate"] = EndDate;
Viewdata [ "EndDate"] = StartDate;
Viewdata [ "Cause"] = causale.GetListaCausaleDropDown ();



return View ( "Search");


)
/ / /
/ / / Implementation of research, and more precisely when the operator clicking on the button passes the parameters
/ / / Will be used to build the Linq query and return the results in the grid.
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
/ / /
[Authorize (Roles = "OP_Bollettino")]
[AcceptVerbs (HttpVerbs.Post)]
[LogError]
public JsonResult Research (FormCollection formcoll)
(

DateTime date = DateTime.Now.Date.AddDays (-30);
data.ToShortDateString EndDate = string ();
data.Date.ToShortDateString ();
string StartDate = DateTime.Now.Date.ToShortDateString ();

date = DateTime.Parse (Request.Form [ "StartDate"]. ToString (). Trim ());

DataFire = DateTime.Parse (Request.Form [ "EndDate"]. ToString (). Trim ());
Viewdata [ "StartDate"] = datai.ToShortDateString ();
Viewdata [ "EndDate"] = dataf.ToShortDateString ();
TRY
(


var search = utente.GetBollettinoBySearch (null, 0, date, DataFire, null);




if (String.IsNullOrEmpty (Request.Form [ "Surname"]))
(
Viewdata [ "checksurname"] = true;
abilitatosur.Add ( "enabled", "enabled");
Viewdata [ "abilitasur"] = abilitatosur;
Viewdata [ "cog"] = Request.Form [ "Surname"]. Trim (). ("''", Replace "");
name = Request.Form [ "Surname"]. Trim (). ("''", Replace "");
utente.GetBollettinoBySearch search = (name, 0, date, DataFire, null);

)
else
(
Viewdata [ "checksurname"] = "false";
abilitatosur.Add ( "Disabled" "Disabled");
Viewdata [ "abilitasur"] = abilitatosur;

)



if (String.IsNullOrEmpty (Request.Form [ "Cause"]))
(

Viewdata [ "checkcausale"] = "true";
abilitatocaus.Add ( "enabled", "enabled");
Viewdata [ "abilitacaus"] = abilitatocaus;
Viewdata [ "selection"] = "Select";
id_causale string = Request.Form [ "Cause"];

utente.GetBollettinoBySearch search = (null, int.Parse (id_causale), date, DataFire, null);
var selectcasuale = causale.GetListaCausaleDropDown (). ToList ();
Viewdata [ "Reason"] = new SelectList (selectcasuale.ToList (), "Value", "Text", id_causale), / / new MultiSelectList (causale.GetListaCausaleDropDown (), "Value", "Text", selected);

)
else
(
abilitatocaus.Add ( "Disabled" "Disabled");
Viewdata [ "checkcausale"] = "false";
Viewdata [ "abilitacaus"] = abilitatocaus;
Viewdata [ "selection"] = "Select";
var selectcausale = causale.GetListaCausaleDropDown (). ToList ();
Viewdata [ "Reason"] = new SelectList (selectcausale.ToList (), "Value", "Text", 0);
)

if (String.IsNullOrEmpty (Request.Form [ "codiceF"]))
(
abilitatocf.Add ( "enabled", "enabled");
Viewdata [ "abilitacf"] = abilitatocf;
Viewdata [ "checkcf"] = true;
Viewdata [ "cf"] = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");
cf = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");
utente.GetBollettinoBySearch search = (null, 0, date, DataFire, cf); / / res.WithCf (cf);
)
else
(
Viewdata [ "checkcf"] = "false";
abilitatocf.Add ( "Disabled" "Disabled");
Viewdata [ "abilitacf"] = abilitatocf;

)



return JSON (datastore = new (search));



)

catch (Exception ex)
(
Utilita.LogError (ex);

return JSON ( "Search");
)


)


I have tested a JavaScript debugger and load the page when I enter the debug extjs grid, even though I click the search button to search back to me the contents of the query in notepad format and I do not even enter into debbugger javascript.

I can help you understand why, I tried it with several examples of extjs but does not work.

Thanks


View Full Details...............................

Pass Regular Expression from view to controller

Hello, i have this problem on my asp.net mvc website (in c#) and i don't know how to solve it.

My web app has one aspx wich the user can create a field to be used later, such an input textbox, drop down list, radiobutton, etc. But in this field, the user can add to it a regular expression to validate the field later. My problem is that i cant pass the regular expression text from view to controller without losing text, and this is because the complexity of a regular expression. I try with encoreUri and encodeElement, but it didn't work. I have to tell that the text of the regular expression that i am passing is with a $.post() of the jquery library.

I hope that you can help me with this problem.

Thanks.

View Full Details...............................

IgnoreRoute

I start looking at MVC framework and trying to learn from ASP.NET/ MVC page. I started with Routing overview and alomost understant the logic. one point that I have issue with is IgnoreRoute property. I have the last version of MVC and in my MVC Project template' global.asax.cs' method RegisterRoutes(RouteCollection routes) i try to follow the tutorial and added ;

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");, but the IgnoreRoute is not a method of RouteCollection. Am i missing something , or is part of the new version
Thanks in advance.

View Full Details...............................

Accessing and Saving a set of fields from a webform

Hello everyone,



I have a set of fields in my webform I want to save/update. Its an overview of categories and prices - so the form represents a couple of datasets an I want to update/save them all at once. One row contains the ID - if not a new dataset, a 2 category ids and a price.

When I try to access them via FormCollection I get all the fields together in one String - what would be ok if there would not be prices. So for example I get the prices returned like 13,30,23,10,50,60. I could split them but as I don't know if the returned values were entered as 13,30 and 23 or 13 and 30,23 thats not really possible.

I think there must be an easy way to do that - maybe someone could help me how to access the data in the right way.

Thanks for your help!



Best regards,

Florian

View Full Details...............................

Parameter for AjaxOptions OnBegin callback ?

Hello,

I'm using asp.net mvc v 1.0 and wondering how I could write the AjaxOptions block so as to pass a parameter to the OnBegin callback. I write relevant code at bottom.

I tested "Test('hello')" but this prevented the ajax call to correctly update the target area (response opened in a new page).

However, when I look at the arguments passed to the callback, I find some, and just miss the correct documentation page. Could someone point me out to it please ? Argument $4 is the JQuery (it seems) object that will be updated by the ajax call. I can do with it, but will it remain in 4th position ? So I need to grab the correct information.

Here are the callback parameters when looking at it with Firebug :

Object $3=Object $4=tbody#d1.tbody_nav $0=0

Here is my code :

------------

string lien = Ajax.ActionLink(nomAffiche, "Lire",
new
{
(skip some request parameters here)
},
new AjaxOptions {
UpdateTargetId = "d1",
HttpMethod = "post",
LoadingElementId = "chargement_d1",
OnBegin = "Test"
},
(skip some html attributes here)
);

----------

function Test(chaine) {
alert('test' + chaine);
}

-------------

Thanks,

Barbara

View Full Details...............................

Model binding to object index

Model binding to object index

A view displays a list of customer details and inserts an index into each id.. like this customer[0].name, customer[1].name, customer[0].phone, customer[1].phone and so on. Also each of these can be posted to an action that has a customer parameter. The model binder is nt working correctly, i assume bcoz of the index customer[0].. Can the deafult model binder do this?

View Full Details...............................

MVC Local Date Input Formatting

MVC Local Date Input Formatting

I've got an MVC app I'm writing that has several input dates in it. Obviously these may be submitted in different formats, depending on the users localisation detail so I need to convert these on the POST method prior to using the UpdateModel method to fire the results through to the data object and its validation code. I believe I should use a custom model binder for this, correct? If so, do I have to create a model binder for each field (they may not all be present on any particular form submission) or can I create one that will apply to all the different field names? Are there any good articles on doing this that anyone knows about (I would have thought this would be a common issue, but I am struggling to find an article that addresses it well).

Cheers

MH

View Full Details...............................