|
Well, my primary problem is EF6. There doesn't appear to be any way to have a ID field that uses a "unique identifier" type in their designer. Instead you have to specify a string, which sql does not consider to be a unique identifier.
So, parsing/deserialization is not the problem. Unless I write actual sql to upsert a new record, I have to create the guid in the model (or viewmodel).
What I'm complaining about is that I can't find any useful reference material that talks about EF6 in the context of MVC, without having all kinds of needless crap about styling the UI on a website. I don't CARE about styling the web site yet.
".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'm afraid I can't speak to the designer; I've never used it.
I have, however, used the GUID type for primary keys with EF6, and I don't remember having any special issues with it (unlike prior EF versions). You should be able to declare a POCO like so:
public class Foo
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Bar { get; set; }
...
}
But beyond that, I think I might be able to help in terms of the documentation piece. MVC.NET is largely targeted towards the sort of people that previously used WebForms, so it's more concerned with the UI than what you need right now. I would suggest looking at documentation for WebAPI instead, if you're trying to work on the backend more than the front. The concepts are just about identical, and none of the UI is injected into it. The only real difference is that in MVC.NET you'll usually end up passing the model to a View constructor rather than returning it directly.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Hi Yaseer,
I have started the implementation of databinding using table given here.
In the example on this site, they have taken fix array to bind the data. As per your example of users database, I have added another page and typescript whose code is mentioned below.
Typescript code:
<pre>import { Component, OnInit, ViewChild } from '@angular/core';
import { UserService } from '../Service/user.service';
import { IUser } from '../Model/user';
import { DBOperation } from '../Shared/enum';
import { Observable } from 'rxjs/Rx';
import { Global } from '../Shared/global';
import { ManageUser } from './manageuser.component';
import { MdDialog, MdDialogRef } from '@angular/material';
import { UserFilterPipe } from '../filter/user.pipe';
import { DataSource } from "@angular/cdk/collections";
import 'rxjs/add/observable/of';
@Component({
templateUrl: 'app/Components/userlist.component.html'
})
export class UserListComponent implements OnInit {
users: IUser[];
user: IUser;
dataSource: userDataSource;
displayedColumns = ['FirstName', 'LastName'];
constructor(private _userService: UserService) { }
ngOnInit(): void {
this.LoadUsers();
this.dataSource = new userDataSource(this.users);
}
LoadUsers(): void {
this._userService.get(Global.BASE_USER_ENDPOINT)
.subscribe(users => { this.users = users }
);
}
}
export class userDataSource extends DataSource<any>{
constructor(private _users: IUser[]) {
super();
}
connect(): Observable<IUser[]> {
debugger;
return Observable.of(this._users);
}
disconnect() { }
}
My HTML:
<pre><div class='panel panel-primary'>
<div class='panel-heading'>
User List using Table
</div>
<div class='panel-body'>
<md-table #table [dataSource]="dataSource">
<ng-container mdColumnDef="FirstName">
<md-header-cell *mdHeaderCellDef> First Name </md-header-cell>
<md-cell *mdCellDef="let element"> {{element.FirstName}} </md-cell>
</ng-container>
<ng-container mdColumnDef="LastName">
<md-header-cell *mdHeaderCellDef> Last Name </md-header-cell>
<md-cell *mdCellDef="let element"> {{element.LastName}} </md-cell>
</ng-container>
<md-header-row *mdHeaderRowDef="displayedColumns"></md-header-row>
<md-row *mdRowDef="let row; columns: displayedColumns;"></md-row>
</md-table>
</div>
</div>
The issue is that I am not getting any scripting error but data is also not binding. Weird thing is that when I debug the typescript in browser, the data gets bind sometimes while debugging.
It will be good if you can throw some light on this.
Please find the steps to upgrade to material
2.0.0-beta.10 dependency below just for your reference.
1. "@angular/material": "2.0.0-beta.7" --> No Change
2. "@angular/material": "2.0.0-beta.8"
2.1 Include "@angular/cdk": "2.0.0-beta.8" in devDependencies
2.2 Change "rxjs": "5.0.1" to "rxjs": "5.0.3" in dependencies
2.3 map bundle '@angular/cdk': 'npm:@angular/cdk/bundles/cdk.umd.js' in systemjs.config.js
3. "@angular/material": "2.0.0-beta.10"
3.1 Change "@angular/cdk": "2.0.0-beta.8" to "@angular/cdk": "2.0.0-beta.10"
3.2 map below bundles in systemjs.config.js
'@angular/cdk/a11y': 'npm:@angular/cdk/bundles/cdk-a11y.umd.js',
'@angular/cdk/bidi': 'npm:@angular/cdk/bundles/cdk-bidi.umd.js',
'@angular/cdk/coercion': 'npm:@angular/cdk/bundles/cdk-coercion.umd.js',
'@angular/cdk/collections': 'npm:@angular/cdk/bundles/cdk-collections.umd.js',
'@angular/cdk/keycodes': 'npm:@angular/cdk/bundles/cdk-keycodes.umd.js',
'@angular/cdk/observers': 'npm:@angular/cdk/bundles/cdk-observers.umd.js',
'@angular/cdk/overlay': 'npm:@angular/cdk/bundles/cdk-overlay.umd.js',
'@angular/cdk/platform': 'npm:@angular/cdk/bundles/cdk-platform.umd.js',
'@angular/cdk/portal': 'npm:@angular/cdk/bundles/cdk-portal.umd.js',
'@angular/cdk/rxjs': 'npm:@angular/cdk/bundles/cdk-rxjs.umd.js',
'@angular/cdk/scrolling': 'npm:@angular/cdk/bundles/cdk-scrolling.umd.js',
'@angular/cdk/table': 'npm:@angular/cdk/bundles/cdk-table.umd.js',
3.3 Change <button mdSuffix [mdDatepickerToggle]="picker"></button> to <md-datepicker-toggle mdSuffix [for]="picker"></md-datepicker-toggle>
3.4 Import below dependencies if using Autocomplete feature
import 'rxjs/add/operator/startWith';
import 'rxjs/add/operator/map';
|
|
|
|
|
Munjal Pandya wrote: Hi Yaseer,
Who is this message meant for?
If you're replying to a message from another user, then reply to that thread.
If you're commenting on an article, then use the forum at the bottom of the article.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes... By mistake I have posted in general Q & A section.
|
|
|
|
|
Hello !
I'm using MVC , C# and Entity Framework.
The object on my model are:
State-------- Id , Name
City ------- Id , Name , StateId
TheObject----Id,Name,StateId,CityId
I want to create an edit form for TheObject.
The Edit form has 2 dropdownlist State and City that are created dynamically , and the City list depend on selection made on State List.
The problem is that the dropdown list are filled correctly , but when the edit form is open these 2 dropdownlist are in empty state and does not have selected the real values for the object that is edited .
The partial code for Edit view is this :
<div class="form-group">
@Html.LabelFor(u => u.State, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(u => u.State,
new SelectList(ViewBag.State, "Id", "Name"),
"Choose State",
new { @class = "form-control", @onchange = "selectCities()" })
@Html.ValidationMessageFor(u => u.State, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(u => u.City, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(u => u.City,
new SelectList(Enumerable.Empty<SelectListItem>(), "Id", "Name"),
"Choose City",
new { @class = "form-control" })
@Html.ValidationMessageFor(u => u.City, "", new { @class = "text-danger" })
</div>
</div>
<script>
function selectCities() {
debugger;
var stateId = $("#State").val();
$.ajax({
url: '/Home/selectCities',
type: 'POST',
datatype: 'application/json',
contentType: 'application/json',
data: JSON.stringify({ stateId: +stateId }),
success: function (result) {
$("#City").html("");
$("#City").append
($('<option></option>').val(null).html("---choose City---"));
$.each($.parseJSON(result), function (i, cty)
{ $("#City").append($('<option></option>').val(cty.Id).html(cty.Name)) })
},
error: function () { alert("Error !") },
});
}
</script>
The partial code of the controller is this :
private void Fill_StateDropDownList()
{
var st = from d in db.States
orderby d.Name
select d;
ViewBag.State = st.ToList();
}
[HttpPost]
public ActionResult selectCities(string stId)
{
List < City > lstcity = new List < City > ();
int stateiD = Convert.ToInt32(stId);
lstgrupet = (from d in db.Citys
where d.StateID==stateiD
select d).ToList();
string result= JsonConvert.SerializeObject(lstgrupet, Formatting.Indented,
new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore});
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
TheObject obj = db.TheObjects.Find(id);
if (user == null)
{
return HttpNotFound();
}
Fill_StateDropDownList()
return View(obj);
}
[HttpPost, ActionName("Edit")]
[ValidateAntiForgeryToken]
public ActionResult EditPost(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var theobjectToUpdate = db.TheObjects.Find(id);
if (TryUpdateModel(theobjectToUpdate, "",
new string[] { "Name","StateId","CityId" }))
{
try
{
db.SaveChanges();
return RedirectToAction("Index");
}
catch (Exception)
{
ModelState.AddModelError("", "Error.");
}
}
Fill_StateDropDownList()
return View(theobjectToUpdate);
}
modified 23-Sep-17 15:02pm.
|
|
|
|
|
Controller:
private void Fill_StateDropDownList()
{
var st = from d in db.States
orderby d.Name
select d;
ViewBag.State = st.ToList();
}
private void Fill_CityDropDownList(int? stateId)
{
var cities = from d in db.Citys
where d.StateID == stateId
select d;
ViewBag.City = cities.ToList();
}
[HttpPost]
public ActionResult selectCities(int? stateId)
{
var cities = from d in db.Citys
where d.StateID == stateId
select new { d.Id, d.Name };
return Json(cities, JsonRequestBehavior.AllowGet);
}
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
TheObject obj = db.TheObjects.Find(id);
if (obj == null)
{
return HttpNotFound();
}
Fill_StateDropDownList();
Fill_CityDropDownList(obj.StateId);
return View(obj);
}
[HttpPost, ActionName("Edit")]
[ValidateAntiForgeryToken]
public ActionResult EditPost(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var theobjectToUpdate = db.TheObjects.Find(id);
if (TryUpdateModel(theobjectToUpdate, "", new string[] { "Name", "StateId", "CityId" }))
{
try
{
db.SaveChanges();
return RedirectToAction("Index");
}
catch (Exception ex)
{
ModelState.AddModelError("", ex);
}
}
Fill_StateDropDownList();
Fill_CityDropDownList(theobjectToUpdate.StateId);
return View(theobjectToUpdate);
}
View:
<div class="form-group">
@Html.LabelFor(u => u.State, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(u => u.State,
new SelectList(ViewBag.State, "Id", "Name"),
"Choose State",
new { @class = "form-control" })
@Html.ValidationMessageFor(u => u.State, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(u => u.City, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(u => u.City,
new SelectList(ViewBag.City, "Id", "Name"),
"Choose City",
new { @class = "form-control" })
@Html.ValidationMessageFor(u => u.City, "", new { @class = "text-danger" })
</div>
</div>
Javascript:
$(function(){
$("#State").change(function(){
debugger;
var stateId = $(this).val();
$.post('/Home/selectCities', { stateId: +stateId })
.done(function(result){
var $city = $("#City");
$city.html("");
$city.append($('<option/>').val(null).html("---choose City---"));
$.each(result, function (i, cty) {
$city.append($('<option/>').val(cty.Id).html(cty.Name));
});
})
.fail(function(){
alert("Error !");
});
});
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello !
i'm new to design Website using MVC.
I'm using entity Framework and C#.
On my Login controller , I get the currently logged user as an entity . ( Users LogUser
But I want to use the variable LogUser in other controllers.
How can I do that , how can can I save as global variable ? ( I have declared LogUser as public but does not work )
Thank you !
|
|
|
|
|
desanti wrote: how can can I save as global variable
You can't.
"Global" variables (aka static fields) are shared across all threads in your process. That means there would only ever be a single value of that variable across all requests from all users.
Instead, you store an authentication ticket in a cookie, which only applies to requests from the current user. You then use that ticket to authenticate the user.
But you shouldn't be writing that code yourself. You should be using ASP.NET Identity[^] to handle authentication for your application.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Do you mean a code like this :
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = HttpContext.Request.Cookies[cookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
string UserName = ticket.Name;
|
|
|
|
|
|
So I'm engaging in my semi-annual technology roundup to determine if there's finally some integration in the standards that will allow me to use certificates on a hardware token to digitally sign a document without going through the process of downloading, signing, and uploading.
I'm not going to write a browser plugin due to the organization security posture.
I'm not terribly interested in using Java for this purpose, in a good part due to the above.
I've been watching the Web Cryptography API with something akin to hope for a few years now. Is anyone aware of any additional projects or WebCrypto integrations that I might have missed?
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I want to create a login page for my site.This is my html code.
<form class="modal-content animate" action="inori.php">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<h1>Member Login</h1>
</div>
<div class="container">
<label>Username</label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label>Password</label>
<input type="password" placeholder="Enter Password" name="psw" required>
<button type="submit">Login</button>
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<input type="checkbox" checked="checked"> Remember me
Forgot <a href="#">password?</a>
</div>
<div class="container" style="background-color:#f1f1f1">
</div>
</form>
I want to create php and ajax code to complete the form. could someone give me a tutorial to do this. I dont have any idea where to start.
modified 17-Sep-17 2:58am.
|
|
|
|
|
PHP 5 Tutorial[^] This worked for me as a getting started in php. They also have AJAX.
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 am wondering if you can tell me if there is anything wrong with the html listed below that is near the 14px listed below?
<p> </p>
<p>&CUR_DATE.EVAL</p>
<p>To the &PAR_NAME.EVAL of &STU_FNAME.EVAL &STU_LNAME.EVAL<br />
<span id="ADDR_BEG"></span>&PAR_ADDR.EVAL<br /><span id="ADDR_NEXT"></span>&PAR_CITY.EVAL, &PAR_STATE.EVAL &PAR_ZIP.EVAL<br /><span id="ADDR_END"></span>
<br />
Dear &PAR_NAME.EVAL and &STU_FNAME.EVAL &STU_LNAME.EVAL:<br />
<br />
This letter is to inform you that &STU_FNAME.EVAL has the equivalent of 5 or more unexcused absences this school year. <span style="font-size: 10pt; font-family: arial,sans-serif; color: black;"><span style="font-size: 14px; font-family: arial;">We believe student attendance in school is a key component to school success, so it is very important for all children to develop habits of good attendance. Poor attendance contributes to failing grades, decreased learning opportunities, lower academic achievement and may limit your child's opportunities to be involved with school activities.</span><br />
<br />
</span><br />
I am asking this question since the value listed above is stored in a varchar(max) column in a sql server 2012 database. When an
ssrs 2012 report is executed, the following error message is displayed:
"Warning 1 [rsParseErrorInvalidSize] Near character position 646 in the input string, the value of the font-size property for the textrun ‘stringtemplate3.Paragraphs[0].TextRuns[0]’ is “14px”, which is not a valid size. Valid sizes may not exceed 455 inches (1155.7 centimeters). ".
|
|
|
|
|
I cannot quite duplicate your environment as I don't have whatever auxiliary files you rely upon.
Loading what you have in my editor and the following occurs:
1) No error messages when rendering (FireFox v55)
2) A number of your values begin with '&' - and that is generally reserved for things such as special characters. Hence my comment about lacking auxiliary files (or even if page is html, php, asp, etc.)
3) within one of your span's, you have id="ADDR_BEG" which appears to paste in my editor (Expressions IV) as a link, but his is an embedded link which you are using as an ID - doesn't seem like a good idea at all! Ditto for "ADDR_NEXT" and "ADDR_END".
Simplify your string by eliminating above items one by one until the error goes away - then fix the cause.
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 |
|
|
|
|
|
You have what looks like SQL components inside of your paragraph tags, that is the first problem.
The second possibly have you tried a different px size? If it is not accepting a larger size try decreasing the amount.
|
|
|
|
|
Hello everyone, Can someone help me with code to add scroll bar inside the popup window (Note: not to the popup window ,i need inside the popup window) so that all the contents in the Popup Window Should be visible or Aceessed.
Here is my code :
Quote:
searchApiOptions = {
store: "7xhosting",
containerId: "divID",
submitURL: "",
selectedTld: "com",
popupBox: true,
floatingBox: false
};
|
|
|
|
|
I want to configure dropzone for removing images, I've done `addRemoveLinks: true` i want the php code to delete that file? How can I get the id of the file to delete? And my second question is how can I upload videos through dropzone? And the third question is how can I restrict size of the files in dropzone?
I've tried this:
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("#myDropzone", {
url: "delete.php",
maxFileSize: 50,
acceptedFiles: ".pdf",
addRemoveLinks: true,
I want the code for delete.php, along with the query..
|
|
|
|
|
You have already posted this in QA: How do I configure dropzone.js?[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I was unable to find a comment on this topic anywhere on the entire Internet, so I shall write this up here, in the hope it helps someone else.
I inherited a web application that runs reports. The web application was composed back in 2004 and sporadically, not to say passive-aggressively, upgraded to .NET 3.5.
When I got it, it was using Crystal Reports (some of us here call it "Meth Reports", or less printable names). The DLLs tell us they are version 14; the file structure tells us they are "SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0". Crystal Reports 2011 is another term I've seen.
In production, on IIS 7.5 / Windows Server 2008R2 / 6.1, it worked about as well as Crystal always worked. Until I tried running it on my machine which is Windows 10.
The offending codeblock:
using (var rasService = iStore.EnterpriseSession.GetService("RASReportFactory"))
{
var rtpAppFactory = (ReportAppFactory)rasService.Interface;
try
{
ReportClientDoc = rtpAppFactory.OpenDocument(reportID, Convert.ToInt32(CdReportClientDocumentOpenOptionsEnum.cdReportClientDocumentRefreshRepositoryObjects));
}
catch (Exception ex)
{
errorMessage = "ERROR: " + ex.Message.ToString();
}
}
.OpenDocument here just bombed without telling us why. I went into the Windows 10 eventvwr, and it told me that IIS 10 had crashed with an "access exception" - that is, 0xC0000005 segmentation-fault. The culprit was ATL80.dll. This is the Active Template Library: involved in interop, in its VS 2005 / C++ form. Which is, I take it, what Crystal Reports "2011" was compiled in.
I think what happened to us here is that IIS 10 no longer allows unmanaged code. ATL80 is of course the very definition of unmanaged.
Given that, if you have a Crystal Reports 2011 application running the .OpenDocument method on Report Application Server, you are locked into not upgrading your web server. You will have to set this up on a VM running legacy IIS or else you will have to, I dunno, not use Crystal.
Unless there are better ideas...
|
|
|
|
|
I've hated Crystal Reports for years...thanks for giving a heads up on a new issue that I'm likely to see in the next couple years.
Have you tried wrapping the crystal reports interface in a managed class? Or better still, setting up the crystal endpoint as a completely separate service (assuming you're using an SoA)?
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
From time to time, my firefox session will get nailed by what I presume to be a script attack from an ad. I'll get an angry large page popup demanding I call an 877 number immediately or else. What it says isn't relevant to my question. What I would like to know is how these bozos generate what I assume to be some client side script that causes the application modal.
I can't close the window, the tab is stuck, the only way to recover is to completely kill off the browsing session with task manager. Setting aside the issue of why in God's name mozilla would even allow this, is there a way to override this?
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
It is probably some add-on of Firefox...
So you should scan both installed softwares (Control Panel) and Firefox add-on list...
Look for anything you do not recognize, find suspicious and remove/disable it...
Have you tried AdBlock or similar?
As for the technical side - an add-on has access to your OS (almost non-restricted) and can do a lot of damage if choose to...
(This is the kind of message you got? Firefox image[^])
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Well, some more technical users from firefox have given me some ideas to try the next time it happens. Warning noted about add-ons, but I know my machine is clean, I scan it pretty regular. Clean firefox install.
General consensus is that this is some JavaScript pulling an application modal stunt. I'm so glad our new HMI will be all in JavaScript.
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|