EmbeddedResourceVirtualPathProvider and #Html.TextBoxFor(Linq expression) - linq

In my .cshtml file, I'm getting an error wherever I use #Html.TextBoxFor
here's a sample code:
#model WebComposite.Models.CompositeModel
<label for="name">Name</label>
#Html.TextBoxFor(m => m.name)
Error:
Error #1:
'System.Web.Mvc.Html.InputExtensions.TextBoxFor<TModel,TProperty>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TProperty>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Error #2:
One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?
any ideas?

in case anyone else is wondering, here's how I resolved it:
1. right click on the project -> select properties
2. select Application
3. change "target framework" (I was at 4.5, so I changed it to 4)
4. change "target framework" to whatever it was before step 3
web.config is cleaned up, appropriate references are added, do a build and everything should be back to normal

Related

How can I select the first option inside a dropdown menu by targeting css?

I'm currently using Cucumber / Selenium / Ruby to create my automation framework and setup my first test. The one I'm working on involves me to fill in a form in order to proceed to the next stage. The form contains a dropdown with multiple values, of which I want to select one (and any one!)
Inspect Element of the Dropdown Menu
<input type="search" class="ember-power-select-trigger-multiple-input" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" id="ember-power-select-trigger-multiple-input-ember3325" aria-controls="ember-power-select-options-ember3325" style="width: 100%;" placeholder="All classes">
I've therefore made use of the class inside my step below:
My Step
#wait.until {#driver.find_element(:css => 'input.ember-power-select-trigger-multiple-input').click}
At the moment, when I run this, it's able to find the correct dropdown option and click it. The options in the list appear, but obviously nothing happens.
What I'd like to know is how I can extend this further so that the dropdown is selected, and that the "first" option is selected? I don't want to specify what it should be, but it just should randomly select the first from the list and use that.
Any thoughts on the easiest way to achieve this?
Research Snippet
I did some research and found the following snippet which I thought I could add to my code, however I'm unsure if it would actually work, or whether I could use this in conjunction with the #wait.until step that I mentioned above?
groupDropdown = #driver.find_element(:css => 'input.ember-power-select-trigger-multiple-input')
option = groupDropdown.find_element(:css, "option:nth-child(1)")
option.click
#wait.until {#driver.find_element(:css => 'input.ember-power-select-trigger-multiple-input').click}
#wait.until {#driver.find_element(:css => '.ember-view > li > .ember-view > li:nth-of-type(1) > .ember-view > li').click}
This worked.
Until
The “until” method within Selenium requires a “truthy” response to continue with the rest of the code.
What you could do is this:
power_select = #driver.find_element(:css => 'input.ember-power-select-trigger-multiple-input')
#wait.until {power_select.displayed?}
power_select.click
This will wait for the element to be displayed on the page, which returns a boolean, and then follow through with a click
Select
Following on from that, the methods for Selects are hidden within the library quite well, but after searching around for a bit:
To Select by text:
Selenium::WebDriver::Support::Select.new(#driver.find_element(:css => <insert_css_of_select_here>)).select_by(:text, <insert_option_text_here>)
To Select by index:
Selenium::Webdriver::Support::Select.new(#driver.find_element(:css => <insert_css_of_select_here>)).select_by(:index, <insert_index_value_here>)
Selecting by index is what you most likely want to do here, setting the index value to 0 to select the first option.
This will let you select required option of ember-power-select with Capybara:
find('.ember-power-select-trigger').click # Open trigger
find_all('ul.ember-power-select-options > li')[1].click # Select 2nd option
Tested with latest ember-power-select.
You might find the click be quite slow if your Capybara.default_max_wait_time is high, so to speed things further you can do this:
find('.ember-power-select-trigger').click # Open trigger
Capybara.using_wait_time(0.1) do
find_all('ul.ember-power-select-options > li')[1].click # Select 2nd option
end

Ember: Specify a target action view for an action helper, other than the containing or parent view

In Ember, if you want an action to be handled by a view, it's easy to achieve this using
<button {{action 'something' target='view'}}>
`{{view App.targetView}}` // this is the view in which the 'something' action ought to be handled
If you wanted the parentView to handle this, then target='view' gets replaced with target='parentView'
Fair enough, my problem is that I want a childView to handle and simply stating 'childView' yields
'Cannot read property 'send' of undefined '
I could choose to specify the name of the view in here, like :
target='targetView'
where
{{view App.targetView viewName="targetView"}}
that did not work. Neither did
target ='views.targetView' nor 'childViews.targetView'
Please don't guide me to change the semantic structure of my app by stating that the button with this action needs to be within the App.targetView template because that to me is a hack and messing with the semantic structure of my app.
What I do need to know is how I can use the target property to specify a specific view, not just the containing or parent view :) ?
To be honest, my instinctive response is "eek, don't do that". But, I'm going to suspend disbelief and stipulate that you have a good reason for wanting to do this.
The reason your approach did not work is that the target property path is evaluated in the template's context (which by default is the controller). Solution: use the view keyword in the property path and chain the viewName of the target view.
e.g.
<button {{action "foo" target="view.targetView"}}>Click me</button>
{{view App.TargetView viewName="targetView"}}
http://emberjs.jsbin.com/aGagORaz/1/edit?html,js,output

How can I get ReSharper to correctly find an MVC3 section in an alternate layout?

R# is incorrectly reporting one of my MVC3 views as having an error. I have 2 layouts, each with different sections defined:
#{
Layout = "~/Views/Shared/layout2.cshtml";
}
#section Layout2Section { #* Layout2Section is red, reported as error by R#. *#
<span>Injected into LayoutSection2</span>
}
The view displays fine in a browser. Here is code from layout2:
#RenderSection("Layout2Section", false)
#if (!IsSectionDefined("Layout2Section"))
{
<span>default layout2 section</span>
}
There is another layout view in ~/Views/Shared named _Layout.cshtml, the default in an MVC3 project. R# is only giving intellisense for sections in _Layout.cshtml, not layout2.cshtml. I have tried prefixing with an underscore, it does not work. If I try to define any section in layout2.cshtml that is not defined in _Layout.cshtml, R# is calling it an error. How to disable this, either to tell R# that the view is a section definer, or to get rid of the "1 file with errors" message?
Update
After derigel's comment, I realized that the above code is not exactly what I have in my project. Specifically, the line that defines the layout uses T4MVC like so:
#{
Layout = MVC.Shared.Views.layout;
}
If I change it to a string as in the original question, the R# error goes away. #Derigel, shall I still create a test project and post to your tracker? I just reproduced the above update in a brand new MVC3 project, after adding the T4MVC lib.
#olivehour Oh, now I get it. It's known limitation of R# - it can detect layouts only in constant string literals. Can you change T4 templates to generate constants instead of readonly fields?

MvcContrib.Mvc3-ci 3.0.75.0 breaking change?

Just updated from MvcContrib.Mvc3-ci 3.0.73.0 to 3.0.75, and the previously working plain ViewUserControl threw a runtime exception:
The model item passed into the dictionary is of type 'System.String', but this dictionary requires a model item of type 'MvcContrib.UI.InputBuilder.Views.PropertyViewModel`1[System.Object]'.
The "offending" editor takes a plain string from the model:
<%: Html.EditorFor(m => m.Model.NEV) %>
Reverting to 3.0.73.0, and the editor works again. Any ideas? (3.0.74.0 also seems to be working)
I had the same issue to and solved it be reverting to version: 3.0.73.0
Uninstall-Package MvcContrib.Mvc3-ci -Force
Install-Package MvcContrib.Mvc3-ci -version 3.0.73.0
I ran into the same error. It seems that if you use anything other than EditorFor it works fine.
So if you know which HTML editor needs to be rendered use that (e.g. #Html.TextAreaFor(x => x.Model.NEV)

TYPO3: Change plugin from USER to USER_INT type

I have a working TYPO3 extension. It is attached this wiki page. How can I change the code of this extension so it is of the USER_INT type? I.e. I don't want TYPO3 to cache the output of this plugin, and want TYPO3 to invoke the extension ever time a page that uses the extension, i.e. disable the caching for this extension.
To disable caching for your extension go to your piX/class.tx_XXX_piX.php file and remove the following line (below your class declaration):
var $pi_checkCHash = true;
You also need to add the following line in the main method (below $this->pi_loadLL();):
$this->pi_USER_INT_obj=1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
grunwalski it's the opposite you have to change this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',1);
to this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',0);
The simpliest way to solve your problem is to go back to Extension Maganer, select your extension, choose "Edit in Kickstarter" from the dropdown menu, and then select the corresponding Frontend plugin to edit it's properties.
Check the first checkbox which means that you want your plugins to be rendered as USER_INT cObjects. After that click the View result button, uncheck all custom PHP files (your own code, like modules and plugins) on the right side and click the WRITE button. Please be careful. If you don't uncheck the checkboxes of your own files, they will be overwritten with dummy files.
The correct and comlete way to do this is a combination of the answers of #arturh and #Mehdi Guermazi:
change the last parameter in the addPItoST43() call in ext_localconf.php from 1 to 0
remove the var $pi_checkCHash = true; line from the property definitions in the head of the pi1 class.
add the $this->pi_USER_INT_obj=1; line to the start of the main() function in pi1.
These changes are identical to what you will get when you use the kickstarter method explained in the solution of #bencuss.
When you have created your extension with Kickstarter you also have to go to the file [yourextension]/ext_localconf.php and change this line
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',0);
to this:
t3lib_extMgm::addPItoST43($_EXTKEY,'piX/class.tx_yourextension_piX.php','_piX','list_type',1);
Edit the file setup.txt of your extension "myext". Change "USER" into "USER_INT".
plugin.tx_myext = USER_INT
plugin.tx_myxt {
This extension will never be cached.

Resources