Intellisense <%= intended <%# Assembly= returned - asp.net-mvc

When I am editing my aspnetmvc views, I begin my code brackets:
<%
and intellisense pops up items like
<%# Assembly...
<%# Control...
<%# etc...
which is fine, but when I continue my line and press the [=] key, it automatically selects
<%# Assembly=%> and completes my tag.
It's not a huge deal, but does slow me down a bit, especially when editing forms with lost of fields.
Has anyone run into this problem in the past and is there a way to either add <%= to intellisense or stop returning the other directives when I hit [=].
I remember seeing the same issue in one of Phil Haacks recent demos (he says something like "What was that?" and then continues on) but I can't remember which one.
Thanks for the help,
Hal

Or there is the simple solution :)
Press these keys: < % Esc =

I think I found an answer. I created the following macro:
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module RecordingModule
Sub CleanupImplementedInterface()
DTE.ActiveDocument.Selection.LineDown(True, 7)
DTE.ActiveDocument.Selection.Text = " {get"
DTE.ActiveDocument.Selection.DeleteLeft(3)
DTE.ActiveDocument.Selection.Text = " get; set; }"
DTE.ActiveDocument.Selection.CharRight
DTE.ExecuteCommand ("Edit.Replace")
DTE.Find.FindWhat = " {"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.Backwards = False
DTE.Find.MatchInHiddenText = True
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.Action = vsFindAction.vsFindActionFind
If(DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
Throw New System.Exception("vsFindResultNotFound")
End If
DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close
DTE.ActiveDocument.Selection.CharLeft
End Sub
Sub Brackets()
DTE.ActiveDocument.Selection.Text = "<%="
End Sub
End Module
Then in the IDE, I opened Tools > Options > Environment > Keybord
In the "Show commands containing:" textbox I typed the name of my macro.
I then selected "Html source editor" in the "Use new shortcut in:" dropdown box and pressed the shortcut key Alt-B.
Now, whenever I need a bracket, instead of using intellisense, I just press Alt-B in the editor.
Ugly, but workable, solution. Hopefully they will fix this in 2010. Haven't looked.

Type Cntl-Z twice and the automatic change will be undone. You can do this for anything unwanted Intellisense suggestions.

Related

Prestashop all translatable-field display none for product page

Just new in Prestashop (1.6.0.6), I've a problem with my product page in admin. All translatable-field are to display:none (I inspect the code with chrome).
So when I want to create a new product I can't because the name field is required.
I thought that it was simple to find the .js whose do that but it isn't.
If somebody could help me, I would be happy.
Thank you for your help
Hi,
I make some searches and see that the function hideOtherLanguage(id) hide and show translatable-field element.
function hideOtherLanguage(id)
{
console.log(id_language);
$('.translatable-field').hide();
$('.lang-' + id).show();
var id_old_language = id_language;
id_language = id;
if (id_old_language != id)
changeEmployeeLanguage();
updateCurrentText();
}
When I set the Id to 1 (default language), it works. It seems that when I load the page, the function is called twice and the last calling, the id value is undefined. So the show() function will not work.
If somebody could help me. Thank you.
In my console, I see only one error
undefined is not a function.
under index.php / Line 1002
...
$("#product_form").validate({
...
But I find the form.tpl template and set this lines in comment but nothing change.
EDIT: According to comment on this link http://forge.prestashop.com/browse/PSCFV-2928 this can possibly be caused by corrupted installation file(s) - so when on clean install - try to re-download and reinstall...
...otherwise:
I got into a similar problem - in module admin page, when creating configuration form using PrestaShop's HelperForm. I will provide most probable cases and their possible solutions.
The solution for HelperForm was tested on PS 1.6.0.14
Generally there are 2 cases when this will happen.
First, you have to check what html you recieve.
=> Display source code - NOT in developer tools/firebug/etc...!
=> I really mean the pure recieved (JavaScript untouched) html.
Check if your translatable-fields have already the inline style "display: none":
Case 1 - fields already have inline style(s) for "display: none"
This means the template/html was already prepared this way - most probably in some TPL file I saw codes similar to these:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $id_lang_default}style="display:none"{/if}>
Or particularly in HelperForm template:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
Case 1 is the most easy to solve, you just have to find, where to set this default language.
Solutions
HelperForm
Look where you've (or someone else) prepared the HelperForm object - something like:
$formHelper = new HelperForm();
...
Somewhere there will be something like $formHelper->default_form_language = ...;
My wrong first solution was to get default form language from context - which might not be set:
$this->context->controller->default_form_language; //THIS IS WRONG!
The correct way is to get the default language from configuration - something like:
$default_lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$formHelper->default_form_language = $default_lang->id;
...this particularly solved my problem...
Other form-creations
If there is something else than HelperForm used for form creations, the problem is still very similar.
You have to find where in files(probably tpls) is a condition for printing display:none for your case - then find where is the check-against-variable set and set it correctly yourself.
Case 2 - fields don't have inline style(s) for "display: none"
This means it is done after loading HTML by JavaScript. There are two options:
There is a call for hideOtherLanguage(), but there is wrongly set input language - that means no language will be displayed and all hidden.Solution for this one can be often solved by solving Case 1 (see above). In addition there can be programming error in not setting the after-used language id variable at all... then you would have to set it yourself (assign in JavaScript).
Some script calls some sort of .hide() on .translatable-field - you will have to search for it the hard way and remove/comment it out.
PS: Of course you can set the language to whatever you want, it is just common to set it to default language, because it is the most easier and the most clear way how to set it.

How to keep TYPO3's RTE from adding an empty line before <ul>s

In TYPO3 4.5 as well as 6.1, whenever I add an unordered list element, RTEhtmlarera (or some of its many processing routines) will add an extra
<p> </p>
before the ul tag on saving the content element.
This happens only once, when the ul is inserted first. When the p tag is removed and the content element is saved again, it won't happen again.
How can this erroneous behaviour be removed?
Hi try set encapsLines to zero..
Setup typoscript:
tt_content.stdWrap.dataWrap >
lib.parseFunc_RTE.nonTypoTagStdWrap.encapsLines >
Not a real solution but maybe a hint in the right direction.
If you write down your list, do not press enter before the first list entry but shift+enter.
Example:
Here comes the list: <<-- AT THIS POINT PRESS SHIFT+ENTER
- a <<-- Here it does not matter if you press enter or shift+enter
- b
- c
- ...
This works for me as a workaround. I've done a lot of research in sysext:rtehtmlarea but nothing worked. So this looks for me like some kind of mysterious bug/feature connected with the "BR to P" (or vice versa) configuration you can define in pageTS or Setup. BTW: I never fully understood this conversion-thing :)
For me with 6.1 this worked:
lib.parseFunc_RTE {
externalBlocks = table, blockquote, ol, ul, div, dl, address, hr
externalBlocks {
ol.stripNL=1
ol.stdWrap.parseFunc = < lib.parseFunc
ul.stripNL=1
ul.stdWrap.parseFunc = < lib.parseFunc
# i have also seen this setting, but didn´t test it:
# blockquote.stripNLprev = 1
# blockquote.stripNLnext = 1
}
}
I removed many lines for this example, be aware that you overwrite previous settings by using {} ..

DynamicUpdateCommand stops working after QlikView restart

I'm using DynamicUpdateCommand inside a macro in this way:
sub addOrder
set choosen = ActiveDocument.Fields("NUMORD").GetPossibleValues
for i = 0 to choosen.Count - 1
set result = ActiveDocument.DynamicUpdateCommand("UPDATE * SET CHOOSE = 'S' WHERE NUMORD = '" & choosen.Item(i).text & "' " )
if result = false then
MsgBox result.ErrorMessage
end if
next
end sub
Dinamic Data Update is enabled.
It works, but, when I close QlikView and reopen it, it doesn't work anymore. Even if try reloading.
I empirically realized that to make it work again I need to click the "Save" button, even without changing anything...
How can I solve this little issue? Maybe is it connected with RAM and way of saving .qvw file to the file system?
Many thanks!
Without any other solution I ended with this workaround, which saves the document programmatically on document opening:
Document Properties... > Triggers > Document Event Triggers > OnOpen > Add Action(s)... > Add > External > Run macro > set Macro name = reactivateDynamicUpdateCommand
Tools > Edit Module...: add this subroutine:
sub reactivateDynamicUpdateCommand
' I know, it's weird
'... but needed to reactivate DynamicUpdateCommand functionality after a restart
ActiveDocument.Save
end sub
It works, though a better solution would be preferred.
Starting from version 11 Dynamic Update can be done as Actions rather than through VB macro. It is preferable to use Actions when possible. However, sometimes even using Dynamic Update action I noticed freezes similar to what you described. I ended up adding one more dummy action right after Dynamic Update (e.g. assigning a value to dummy variable or adding Selection -> Back action to compensate triggering OnSelect).

ADODBCould not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly

I'm trying to read an ADOBD.Recordset object like this (my first time, so pardon my "noobness" :D):
Presentation.Category categorySvc = new Presentation.Category();
ADODB.Recordset categories = categorySvc.ListAll("BE", "DUE", "EN", 128);
foreach (var category in categories.Fields) // here is where I get the exception
{
// ...
}
The ListAll call works fine - I get the Recordset with some data which I confirm that by doing a QuickWatch on the object. But when the code reach the categories.Fields I get the following exception:
Could not load type
'ADODB.FieldsToInternalFieldsMarshaler'
from assembly 'TestCOMCalls,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'.
I googled this error (or just by 'ADODB.FieldsToInternalFieldsMarshaler' and couldn't find anything that would help me with issue).
I wonder, am I missing a reference? Besides the normal references I have added this one to my project:
ADODB
Microsoft ActiveX Data Objects 2.5 Library
C:\WINDOWS\assembly\GAC\ADODB\7.0.3300.0__b03f5f7f11d50a3a\ADODB.dll
Like I said, I've never done this before but by googling a bit I was able to see some people doing this (foreach on the object.Fields) and it seem to work for them.
Any help or direction is greatly appreciated :)
Thanks!
It's on the individual references - not in the project properties. In the solution explorer window, open "References" (under the project), and click on the reference in question. The properties window will have an option for Embed Interop Types (for each reference).
In Visual BAsic 2010:
To turn off Embed Interop Types:
Project menu > Show All Files, Solution Explorer: > References: > ADODB > Embed Interof types = False. Microsoft.Office.Interop.Access > Embed Interof types = False
You will now be able to publish and also ADODB will appear in the: Project Menu > Project Properties… Publish TAB > Application Files
Solved:
Solution Explorer --> Show all files (Menu Item) --> Referances --> Adodb -->(properties) -->Embed Interop Types --> False.
See what I found on this question here. I referenced yours, but still couldn't get the ADODB to work.
Little one to add:
SolutionExplorer --> View All Files.
For ADODB:
- Embed... = False;
- Copy Local = True.
Got the same problem in VS 2013, and the solution for that is that you go to
References and select ADODB, on properties you will see Embed Interof types = True then change it to false.
I got this problem clearing temporary file(VS 2017). Solution for this exception you need to change Solution Explorer > References > adodb > "Then Right click and choose properties" > Embed Interop Types, set "True" to "False"
Okay, I figured how to do this:
Presentation.Category categorySvc = new Presentation.Category();
ADODB.Recordset categories = categorySvc.ListAll("BE", "DUE", "EN", 128);
categories.MoveFirst();
while(!categories.EOF)
{
var fields = ((dynamic)categories).Fields;
for (int i = 0; i < fields.Count; i++)
{
var field = fields[i];
var name = field.Name;
var value = field.Value;
// ...
}
categories.MoveNext();
}

Fastest way to insert replacement characters in Visual Studio

I'm just starting to pick up ASP.Net MVC and find myself writing a lot of <%= %> in the views. Intellisense does supply the closing %>, but I find that typing the introductory <%= to be burdensome (they are tough for me to type :-)).
I've dabbled around a bit with Rails and the NetBeans IDE where I was able to type:
r<tab> - which would expand to <% %>
and
re<tab> - which would expand to <%= %>
Can something similar be done in the Visual Studio 2008 IDE?
Based on a comment, I double-checked the snippets answer below and it unfortunately doesn't run in HTML view. The other way to do this is via a recorded macro:
In your web project, start recording: CTRL+SHIFT+R
Type <%= %> then return the caret to between the spaces after the "="
Stop recording: CTRL+SHIFT+R
Insert the macro via CTRL+SHIFT+P
That could be enough, but it would be better to have it across all projects, plus we'd like a better keystroke than CTRL+SHIFT+P:
Save the Macro: Tools->Macros->Save Temporary Macro, giving it a name
Bind it to a keystroke combination:
Tools->Options, and choose the Keyboard node
Search for the name you chose
Enter a key combination (e.g. ALT+A) and click OK
Now you can press the key shortcut (e.g. ALT+A) in HTML view, it will insert <%= %>, and position the caret in the tags, ready for input.
[Old Answer: doesn't work in HTML view, unfortunately.]
For a Code Snippet, create an XML snippet file (e.g. "asp.snippet") with the name, shortcut and expansion, then use Tools -> Code Snippet Manager to add the folder where your snippet is stored.
Here's the XML for snippet that (via "asp[tab][tab]"), expands "<%= [code] %>"
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>ASP Server Tags</Title>
<Author>Chris Bowen</Author>
<Shortcut>asp</Shortcut>
<Description>ASP.NET server escape characters, including equals</Description>
<SnippetTypes>
<SnippetType>SurroundsWith</SnippetType>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>code</ID>
<Default>Code</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[<%= $code$ $selected$%>$end$]]>
</Code>
</Snippet>
</CodeSnippet>
More details are here on MSDN.
BTW, VS has a snippet to create snippets. Just open a new XML file, then right click and choose Insert Snippet -> "Snippet".
This macro function should do it:
The main code will do one of two things, if nothing is selected it will just insert the <%= %> code construct, if you have something currently selected in the editor, it will wrap that code with the construct E.G. <%= selected code here %>
Public Sub WrapMVC()
Try
DTE.UndoContext.Open("Wrap MVC")
Dim OutText As String = ""
Dim OutFormat As String = "<%={0} %>"
DTE.ActiveDocument.Selection.Text = String.Format(OutFormat, ActiveWindowSelection)
Finally
DTE.UndoContext.Close()
End Try
End Sub
Helper Routines:
Friend Function ActiveWindowSelection() As String
If DTE.ActiveWindow.ObjectKind = EnvDTE.Constants.vsWindowKindOutput Then
Return OutputWindowSelection()
End If
If DTE.ActiveWindow.ObjectKind = "{57312C73-6202-49E9-B1E1-40EA1A6DC1F6}" Then
Return HTMLEditorSelection()
End If
Return SelectionText(DTE.ActiveWindow.Selection)
End Function
Private Function HTMLEditorSelection() As String
Dim hw As EnvDTE.HTMLWindow = ActiveDocument.ActiveWindow.Object
Dim tw As TextWindow = hw.CurrentTabObject
Return SelectionText(tw.Selection)
End Function
Private Function OutputWindowSelection() As String
Dim w As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim ow As OutputWindow = w.Object
Dim owp As OutputWindowPane = ow.OutputWindowPanes.Item(ow.ActivePane.Name)
Return SelectionText(owp.TextDocument.Selection)
End Function
Private Function SelectionText(ByVal sel As EnvDTE.TextSelection) As String
If sel Is Nothing Then
Return ""
End If
If sel.Text.Length <= 2 Then
SelectWord(sel)
End If
If sel.Text.Length <= 2 Then
Return ""
End If
Return sel.Text
End Function
Private Sub SelectWord(ByVal sel As EnvDTE.TextSelection)
Dim leftPos As Integer
Dim line As Integer
Dim pt As EnvDTE.EditPoint = sel.ActivePoint.CreateEditPoint()
sel.WordLeft(True, 1)
line = sel.TextRanges.Item(1).StartPoint.Line
leftPos = sel.TextRanges.Item(1).StartPoint.LineCharOffset
pt.MoveToLineAndOffset(line, leftPos)
sel.MoveToPoint(pt)
sel.WordRight(True, 1)
End Sub
I believe Code Snippets would fit the bill.
I've found it straight forward to write a macro and then bind it to a keyboard command.
I use Tools->Macros->Macro Explorer to see what's there and you can create a new module and add in a macro to inject your code. Then you bind it to a key with Tools->Customize->Keyboard...
Since it's not too different from what you're doing, here is a macro to inject a source command with the date and username - VBScript - I didn't look to hard for other alternatives.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Module1
Private Function GetUserName() As String
GetUserName = System.Environment.UserName
End Function
Sub InjectChangeComment()
ActiveDocument().Selection().Text = "// " + System.DateTime.Now.ToString("MM-dd-yy") + " " + GetUserName() + vbTab + vbTab + vbTab
End Sub
End Module
Code Snippets in the HTML view do not work. It's slated for the next version of Visual Studio. I'd look at a Macro approach for now, or see if other tools allow for snippets in the HTML editor.
One good tool which will allow you to do this is Resharper. You can create your own templates that will do what you require but also have surround with tags too. There are a whole host of features and is well worth it for the price.

Resources