|
var elt = document.getElementById(elementId);
return elt.options[elt.selectedIndex].text; The correct javaScript dom access can be determined from the bold text, above, after you modify it to your purposes.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
|
I hardly remember even answering this.
There are always packages for pretty much everything.
Tell someone the answer is "get a package" is occasionally appropriate but the answer I gave also allows the poster to learn something about what's going on.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Don't worry - "Sarah" is a spammer.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Fully patched Win7
VS2013/5
.Net 4.5
EF6.2
MVC5
Everything has been going almost okay up until today. All of a sudden, when I try to add a new controller with views, I get this:
There as an error running the selected code generator:
"Exception has been thrown by the target of an invocation."
I was able to add a new controller yesterday with NO PROBLEM with the same dbcontext .
---------------
In the web.config (which has not change since I started the project):
1) There are no instances of "configsource" in the sections.
2) The configSections element is the first element.
3) The entityframework section looks correct (some people have had the wrong provider specified).
4) None of the sections are duplicated.
I've tried the following, and STILL have the problem.
1) The model object appears to be defined correctly, and is implemented as a DbSet<> in the dbcontext ).
2) I tried changing the model implementation in the dbcontext to IDbSet<> .
3) I tried adding a controller (with a different name, of course) for a model that I already created a controller for.
4) I updated EF6 to from 6.13 to 6.2 out of desperation.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I've done everything but start the project over, and I'm not inclined to do that...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Hi everyone, I have a bootstrap tabs inside an updatepanel, i put in a javascript to keep the status of the tab after postback but this causes the following error on every callback:
Sys.WebForms.Res is undefined
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="Tabs" role="tabpanel">
<div class="row row-text">
<div class="col-md-4">
<p class="h5">
search
Effettua Ricerca per:
</p>
</div>
<div class="col-md-8 flex">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#rapida" aria-controls="home" role="tab" data-toggle="tab" class="btn" onclick="javascript: document.getElementById('TabName').value = 'rapida';">Ricerca rapida</a></li>
<li role="presentation"><a href="#tecnica" aria-controls="profile" role="tab" data-toggle="tab" class="btn" onclick="javascript: document.getElementById('TabName').value = 'tecnica';">Ricerca tecnica</a></li>
<li role="presentation"><a href="#veicolo" aria-controls="messages" role="tab" data-toggle="tab" class="btn" onclick="javascript: document.getElementById('TabName').value = 'veicolo';">Ricerca veicolo</a></li>
</ul>
</div>
</div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="rapida">
<div class="row">
<div class="col-md-11">
<asp:TextBox ID="SearchText" runat="server" CssClass="form-control"></asp:TextBox>
</div>
<div class="col-md-1 no-padding-l">
<asp:Button ID="SearchTextStart" runat="server" CssClass="btn btn-first-color btn-first-color--block" Text="Cerca" />
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="tecnica">
<div class="row">
<div class="col-md-11">
<asp:DropDownList ID="SearchCategory" class="form-control" runat="server"></asp:DropDownList>
</div>
<div class="col-md-1 no-padding-l">
<asp:Button ID="SearchCategoryStart" runat="server" CssClass="btn btn-first-color btn-first-color--block" Text="Cerca" />
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="veicolo">
<div class="row">
<div class="col-md-11">
<div class="col-md-6">
<asp:DropDownList ID="SearchBrand" runat="server" CssClass="form-control" AutoPostBack="true" EnableViewState="true"></asp:DropDownList>
</div>
<div class="col-md-6 no-padding-l">
<asp:DropDownList ID="SearchModel" runat="server" CssClass="form-control"></asp:DropDownList>
</div>
</div>
<div class="col-md-1 no-padding-l">
<asp:Button ID="SearchModelStart" runat="server" CssClass="btn btn-first-color btn-first-color--block" Text="Cerca" />
</div>
</div>
</div>
</div>
</div>
<asp:HiddenField ID="TabName" runat="server" ClientIDMode="Static" />
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
$(function () {
SetTabs();
});
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm != null) {
prm.add_endRequest(function (sender, e) {
if (sender._postBackSettings.panelsToUpdate != null) {
SetTabs();
}
});
};
function SetTabs() {
var tabName = $("[id*=TabName]").val() != "" ? $("[id*=TabName]").val() : "personal";
$('#Tabs a[href="#' + tabName + '"]').tab('show');
$("#Tabs a").click(function () {
$("[id*=TabName]").val($(this).attr("href").replace("#", ""));
});
};
</script>
in codebehind :
If Me.IsPostBack Then
TabName.Value = Request.Form(TabName.UniqueID)
End If
modified 8-Nov-17 11:51am.
|
|
|
|
|
When I click logoff, it does not log the user off (it doesn't even hit the method in the Account controller).
In IE11 it's fine. WTF?!!!
Furthermore, EVERY other link is a MVC actionlink, but "Logoff" is this:
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
What's the reason for that?
BTW, I'm using Chrom 61.0.3163.100. I know the latest version is 62...., but I don't have permissions to update it at work.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 7-Nov-17 8:24am.
|
|
|
|
|
John Simmons / outlaw programmer wrote: What's the reason for that?
Because that's how it's declared in Views\Shared\_LoginPartial.cshtml :
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>
}
}
else
{
...
It's using a <form> because the LogOff action in the AccountController requires a POST request:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction("Index", "Home");
}
This is done to prevent a forged request from another site from logging the user out of your site. If you're not worried about that, you could remove the [HttpPost] and [ValidateAntiForgeryToken] attributes to make the action accept a GET request, and then remove the form:
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
</li>
<li>
@Html.ActionLink("Log off", "LogOff", "Account")
</li>
</ul>
}
else
{
...
public ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
return RedirectToAction("Index", "Home");
}
Otherwise, you'll need to work out why the javascript: link isn't working in Chrome. The developer console (F12) might have some clues.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In chrome, I have this:
Refused to load the script '[script name]' because it violates the following Content Security Policy directive: "script-src 'none'".
For each for the following scripts:
modernizr-2.8.3.js
jquery-3.2.1.js
bootstrap.js
respond.js
browserLink (wtf is that?)
It says it refused to load those scripts, but everything else appears to work fine.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
No, I haven't set one because I wasn't aware that I need too.
By addons, do you mean nugget packages?
How would I be able to determine that?
(all of the above could also be asked like this - "How the f*ck should I know?")
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
No, I mean Chrome extensions. Check in chrome://extensions/[^], or "Menu ⇒ More tools ⇒ Extensions" to see what's installed.
You could try starting Chrome in "safe mode" to see if that fixes the issue.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Nope, I haven't installed any extensions, but ScriptSafe is installed.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
That's almost certainly the cause of the problem. AFAIK, Chrome script blockers inject a custom CSP to prevent scripts from executing, which matches the errors in the console.
If you click on the icon, there should be an option to trust or unblock your local site.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I disabled scriptsafe, and now it works.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Cross check ActionName , Controller Name and Methode type(POST/GET)
Spacially Forgery token on both side
|
|
|
|
|
I found out how to align the checkbox with the fields, and then how to vertically center the checkbox with the label, but nothing I've tried lets me make the checkbox 2x larger. I've tried various combinations of height, line-height, padding, and margin, but nothing seems to affect the size.
I don't want to modify the bootstrap files to do this. Can anyone help?
EDIT/UPDATE/RESOLUTION ==================================
I finally came to a somewhat reasonable resolution that appears to work in all browsers.
I have adapted all checkboxes to the following:
<div class="form-group">
@Html.LabelFor(m => m.RememberMe, new {@class = "col-md-2 control-label", @style="color:transparent;"})
<div class="col-md-10">
<label class="btn btn-default">
@Html.CheckBoxFor(m => m.RememberMe) Remember me
</label>
</div>
</div>
And in all actuality, I have an extension method that I use that reduces the above to the following
@Html.CheckBoxForEx(m => m.RememberMe)
The extension method has a labelText parameter that defaults to null, and if that parameter is null, it tries to get the display name for the specified expression. The method also does all the element wrapping and styling, so if I change that stuff in the method, the change is realized throughout the site with no further changes. I've created similar extension methods for most of the MVC Html.Helper methods. My entire Login form looks like this:
@Html.TextBoxForEx(m => m.Email);
@Html.PasswordForEx(m => m.Password)
@Html.CheckBoxForEx(m => m.RememberMe)
@Html.ActionInputButton("LogIn", "Log in")
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
modified 16-Nov-17 10:53am.
|
|
|
|
|
In Chrome, Edge and IE11, setting the width and height seems to work:
Edit fiddle - JSFiddle[^]
In Firefox, that makes the input occupy a larger area, but leaves the box the same size.
Earlier browser versions also have problems. The simplest option is probably to create a custom checkbox element, as described on MDN:
Advanced styling for HTML forms - Learn web development | MDN[^]
But that can get quite fiddly, between changing the image sizes and the padding and positioning of the sprite.
Another option would be to use the transform[^] property to scale the element up:
Edit fiddle - JSFiddle[^]
But that then causes it to overlap the surrounding content, so you'd have to add margins to push the siblings out of the way:
Edit fiddle - JSFiddle[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I've already tried transform, and that didn't work either.
Something weird - I specified an EditorFor container with the bool field, and I got an editor box (for text) overlaid with a checkbox that was as tall as the editor box. When I changed it to a CheckBoxFor, it reverted back to its original too-small-for-my-taste size.
BTW, I'm using chrome in VS...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I found a way. I created a new stylesheet, added it to the end of the style bundle loader:
bundles.Add(new StyleBundle ("~/Content/css").Include("~/Content/bootstrap.css","~/Content/site.css","~/AppCode/StyleMods.css"));
and put this style into it:
input[type="checkbox"]
{
height: 26px;
width: 26px;
margin-top:-3px;
}
Of course, this applies to all checkboxes on the site, but that's what I want, so silver linings. Mo bettah buttah.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
That doesn't work in Firefox - the input takes up more room, but the checkbox stays the same size.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I can't try this until I get home (we don't/can't have FF here at work), but try adding this to the style:
moz-appearance:none;
(This is the biggest reason that I generally despise web development.)
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
That just makes the checkbox disappear completely!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I also found this link:
Advanced styling for HTML forms - Learn web development | MDN[^]
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|