Search Results

Search found 7 results on 1 pages for 'wh0empah'.

Page 1/1 | 1 

  • ASP MVC C#: LINQ Foreign Key Constraint conflicts

    - by wh0emPah
    I'm having a problem with LINQ. I have 2 tables (Parent-child relation) Table1: Events (EventID, Description) Table2: Groups (GroupID, EventID(FK), Description) Now i want to create an Event an and a child. Event e = new Event(); e.Description = "test"; Datacontext.Events.InsertOnSubmit(event) Group g = new Group(); g.Description = "test2"; g.EventID = e.EventID; Datacontext.Groups.InsertOnSubmit(g); Datacontext.SubmitChanges(); When i debug, i can see that after inserting the event. the EventID has gotten a new value (auto increment). But when Datacontext.SubmitChanges(); gets called. I get the following exception "The INSERT statement conflicted with the FOREIGN KEY constraint ... I know this can be solved by creating a relation in the LINQ diagram between Events and groups. And then setting the entity itself. But i don't want to load the events everytime i ask a list of groups. All i need is some way that when inserting the group fails, the event insert won't be comitted in the database. Sorry if this is a bit unclear, My english isn't really good. Thanks in advance!

    Read the article

  • ASP.NET MVC: Html.Actionlink() generates empty link.

    - by wh0emPah
    Okay i'm experiencing some problems with the actionlink htmlhelper. I have some complicated routing as follows: routes.MapRoute("Groep_Dashboard_Route", // Route name "{EventName}/{GroupID}/Dashboard", // url with Paramters new {controller = "Group", action="Dashboard"}); routes.MapRoute("Event_Groep_Route", // Route name "{EventName}/{GroupID}/{controller}/{action}/{id}", new {controller = "Home", action = "Index"}); My problem is generating action links that match these patterns. The eventname parameter is really just for having a user friendly link. it doesn't do anything. Now when i'm trying for example to generate a link. that shows the dashboard of a certain groep. Like: mysite.com/testevent/20/Dashboard I'll use the following actionlink: <%: Html.ActionLink("Show dashboard", "Group", "Dashboard", new { EventName_Url = "test", GroepID = item.groepID}, null)%> What my actual result in html gives is: <a href="">Show Dashboard</a> Please bear with me i'm still new at ASP MVC. Could someone tell me what i'm doing wrong? Help would be appreciated!

    Read the article

  • ASP MVC 2: Error with dropdownlist on POST

    - by wh0emPah
    Okay i'm new to asp mvc2 and i'm experiencing some problems with the htmlhelper called Html.dropdownlistfor(); I want to present the user a list of days in the week. And i want the selected item to be bound to my model. I have created this little class to generate a list of days + a short notation which i will use to store it in the database. public static class days { public static List<Day> getDayList() { List<Day> daylist = new List<Day>(); daylist.Add(new Day("Monday", "MO")); daylist.Add(new Day("Tuesday", "TU")); // I left the other days out return daylist; } public class Dag{ public string DayName{ get; set; } public string DayShortName { get; set; } public Dag(string name, string shortname) { this.DayName= name; this.DayShortName = shortname; } } } I really have now idea if this is the correct way to do it Then i putted this in my controller: SelectList _list = new SelectList(Days.getDayList(), "DayShortName", "DayName"); ViewData["days"] = _list; return View(""); I have this line in my model public string ChosenDay { get; set; } And this in my view to display the list: <div class="editor-field"> <%: Html.DropDownListFor(model => model.ChosenDay, ViewData["days"] as SelectList, "--choose Day--")%> </div> Now this all works perfect. On the first visit, But then when i'm doing a [HttpPost] Which looks like the following: [HttpPost] public ActionResult Registreer(EventRegistreerViewModel model) { // I removed some unrelated code here // The code below executes when modelstate.isvalid == false SelectList _list = new SelectList(Days.getDayList(), "DayShortName", "DayName"); ViewData["days"] = _list; return View(model); } Then i will have the following exception thrown: The ViewData item that has the key 'ChosenDay' is of type 'System.String' but must be of type 'IEnumerable<SelectListItem>'. This errors gets thrown at the line in my view where i display the dropdown list. I really have no idea how to solve this and tried several solutions i found online. but none of them really worked. Ty in advance!

    Read the article

  • ASP MVC: Sending an E-mail

    - by wh0emPah
    Okay I'm kindoff new to the .NET platform. And currently i'm learning ASP MVC. I want to send an e-mail from my program and i have the following code: public void sendVerrificationEmail() { //create the mail message MailMessage mail = new MailMessage(); //set the addresses mail.From = new MailAddress("[email protected]"); mail.To.Add("[email protected]"); //set the content mail.Subject = "This is an email"; mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color=#336699>This is blue</font>"; mail.IsBodyHtml = true; //send the message SmtpClient smtp = new SmtpClient("127.0.0.1"); smtp.Send(mail); } Now when i execute this code i'll get the following exception: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25 Now i'm very very new to the IIS manager & stuff. so there is probably something wrong there. Do i need to install a virtual smtp server or something?. Currently i have following settings (sorry not allowed to uplaod images yet =) ): http://img153.imageshack.us/img153/695/capture2p.png I've been looking for a few hours now but i can't seem to find a working solution. Help would be appreciated! Tyvm.

    Read the article

  • ASP MVC 2: Regular expression attribute working on clientside but not on serverside

    - by wh0emPah
    [Required(ErrorMessage = "Date is required")] [RegularExpression(@"^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$", ErrorMessage="Date is not valid must be like (dd/mm/jjjj)")] public DateTime Startdate{ get; set;} The client-side validation works perfectly. So it seems that JavaScript can successfully understand my regular expression. But when I do a postback, and the modelstate.Isvalid() gets called. My date isn't valid anymore. So I'm guessing that when .NET performs the matching with the regEx it doesn't match. My question: Why does this regular expression match on the client side but not on the server side?

    Read the article

  • ASP MVC: E-mail Verification (Encrypting the activation link)

    - by wh0emPah
    Okay i'm a little bit stuck on how to solve this problem. When a user registers. I want to send him a link so that he can verify hes email address. But i have troubles generating the link. I've already written the controller to accept the links with the correct keys. i only have no idea on how to generate the activation keys. So when the user registers i'll send him a link by mail like this: Your activation link is : http://site.com/user/verify?key=keyhere Now i have created this method (called by the controller/action) to handle the key in the link: public string Verify(string value) { String email = Decrypt(value); user u = gebRep.GetUsers().WithEmail(email).SingleOrDefault(); if (u != null) { u.emailValid = true; userReppository.Save(); } return "Invallid validation value!"; } Now my problem is I have no idea on how to encrypt and decrypt the email into some sort of key (url friendly) So i can mail it with the link and can use it to verify the email. I need some kind of (not to complicated but secure) way to encrypt the email into a urlfriendly key. Tyvm

    Read the article

  • ASP MVC C#: Is it possible to pass dynamic values into an attribute?

    - by wh0emPah
    Okay I'm very new to C# and i'm trying to create a little website using ASP MVC2. I want to create my own authorization attribute. but i need to pass some values if this is possible. For example: [CustomAuthorize(GroupID = Method Parameter?] public ActionResult DoSomething(int GroupID) { return View(""); } I want to authorize the access to a page. but it depends on the value passed to the controller. So the authorization depends on the groupID. Is this possible to achieve this in any way?. Thanks in advance.

    Read the article

1