Calling normal method in Asp.net MVC to insert record without ActionResult redirect - asp.net-mvc-4

Here is my scenario. I have a main view with a datatable. That datatable has a child record that contains a partial view that is loaded when clicked. That partial view has its own button created to insert a record into the database using #URL.Action() that calls the current Action Result. My issue is that I don't need to reload the page or really have the page do anything. When I click the button I just want a simple method to fire (doesn't need to return any action result) so I can run my code to check for existing records in the database, if not create a new one and insert it. Everything I have tried either redirects the page, reloads it or creates an blank page return. I feel like I am missing some simple. I just want to call a typical method by clicking the button from the partial view that has the form data. Can someone tell me what I am missing or have I just been staring at it too long.

Related

How to update fields before the view is displayed in Odoo

I could not figure how I'm supposed to do the following scenario;
I've two fields in my inherited res.partner view "ExternalID" and "ExternalCode" all the fields are going to be editable until those two are filled. And after these two are filled everything is going to be read-only that's the easy part we can handle this by attrs. The problem is when these two fields are filled (they're being filled from an external app by odoo web API.) I need call an external web API before the form is loaded i^ve to update the read-only fields. I've tried placing a computed field and make it invisible so that it gets fired up when the view is being loaded and I thought I should update the other fields but it seems when I write a compute function it can only update the field that it is called from.
For Example;
external_api_call_field = fields.Char(compute='_get_values_from_api')
#api.multi
def _get_values_from_api(self):
for record in self:
#call api and do stuff
#set the values that we got from the external application
record.company_detailed_address="Sample address line"
the method gets triggered and seems to run all the way but when the form is loaded the address field is not filled.
I tried to call
self.write({'company_detailed_address' : 'Sample address line'})
which seems to work but the new value is not set directly you've to refresh the view
Any help or guidance is appreciated.
Regards.

Can someone explain FormCollection parameter in ASP.NET MVC?

I have a web application and it has two controller classes. The two controllers have an action with FormCollection parameter with HTTPPost attribute decorated. If I click on Form submit button then which action will be triggered to capture the form's values within the controller.
Using the Form Collection class we can capture the form's values within the controller.There are many ways to fetch these values and Form Collection is the one of them.
http://tutorial.techaltum.com/Form-collection-in-MVC.html
http://www.c-sharpcorner.com/UploadFile/dacca2/understand-formcollection-in-mvc-controller/
Follow above link It will help you to understand more.

CRM 2013 WebResource IFrame

I have an HTML web resource in an opportunity that produces a css tab control containing all children opportunity to the current record.
I do this through Ajax and javascript and everything works fine, a new tab is made for each child and it shows an opportunity record inside; the only issue is that it will only show the current record inside of this tab - effectively creating an endless loop.
If I paste the URL from the IFrame into the browser it shows the proper record using the right form that I specify(one that doesn't contain another web resource).
Does anyone know why it wouldn't show the same form as it navigates to? If I try google.com it works, just not for this URL:
http://server/CRM/main.aspx?etn=opportunity&pagetype=entityrecord&navbar=off&id=%7B"+val.OpportunityId+"%7D&extraqs=formid%3DC1EC704C-D29B-4786-806F-195D0A80CF07%0D%0A#255409204
Try constructing the URL with this format:
http://server/CRM/main.aspx?etc=3&extraqs=formid%3dC1EC704C-D29B-4786-806F-195Dā€Œā€‹0A80CF07%7d&id=%7b<EnterOppIdHere>%7d&pagetype=entityrecord
Use the Entity Type Code (etc parameter) instead of the Name (etn) and note that everything after that should be part of the extraqs parameter.

Using specific controller in layout - CakePHP

I'm newbie in CakePHP and I have a few questions.
I'm trying to set up my first CakePHP website, and I want to display menu with links in my layout. I've created model called MenuItem, then I've created controller "MenuItemsController" and then a function show. When I access /menuitems/show/ all my links are displayed. So here's the problem. I want do call this controller in my layout so links will be visible on every subpage. First question is how to call this controller, and second how will output look like ? Do I have to create view for this cotroller if I don't want to use /menuitems/show/ or it's okay to set controller to output just array of data ?
Thank you!
First question is how to call this controller, and second how will output look like ?
Use requestAction() to request the data from the view OR better, set it based on the page you're on in your AppController::beforeFfilter() method.
In your layout simply use an element $this->element('menu'); and use the set data in it or, if you go for requestAction() do this call inside the element, you can even cache the element.
Read the links to the CakePHP book in the text, the book contains example code as well.

MVC 4 View open another view

I am using MVC 4 with some Kendo UI and I am new to both.
What I need is for my Kendo grid to redirect to another page when a row is clicked.
My initial thought was to create a function within the script section of the view that the grid is on and that function would call the other view that I need. However, I am not sure if this is possible because I believe the view is supposed to be separate from the controller.
I think that I need to somehow make all of this be able to work from within the controller but I am not sure how to get started.
Use #Ajax.ActionLink to call controller and receive partialView
If you are doing a post action you can use RedirectToAction() in your controller. If you need to change the window in JavaScript see below.
window.location.href = "#Url.Action("(Action)","(Controller)",new {id= (params)})";