Click here to Skip to main content
14,742,951 members
Home » Discussions » ASP.NET
   

ASP.NET

 
Questionweb form gridview control Pin
dcof23-Aug-16 8:08
Memberdcof23-Aug-16 8:08 
QuestionI have thousands of user who are accessing my site, How should I handle a load ? Pin
Abhijit Mindcraft22-Aug-16 23:57
MemberAbhijit Mindcraft22-Aug-16 23:57 
AnswerRe: I have thousands of user who are accessing my site, How should I handle a load ? Pin
deepankarbhatnagar23-Aug-16 1:20
professionaldeepankarbhatnagar23-Aug-16 1:20 
GeneralRe: I have thousands of user who are accessing my site, How should I handle a load ? Pin
Abhijit Mindcraft23-Aug-16 1:48
MemberAbhijit Mindcraft23-Aug-16 1:48 
GeneralRe: I have thousands of user who are accessing my site, How should I handle a load ? Pin
deepankarbhatnagar23-Aug-16 4:43
professionaldeepankarbhatnagar23-Aug-16 4:43 
GeneralRe: I have thousands of user who are accessing my site, How should I handle a load ? Pin
Abhijit Mindcraft23-Aug-16 21:45
MemberAbhijit Mindcraft23-Aug-16 21:45 
GeneralRe: I have thousands of user who are accessing my site, How should I handle a load ? Pin
jkirkerx25-Aug-16 10:20
professionaljkirkerx25-Aug-16 10:20 
Questionadd data to more table relation in same time Pin
ahmed_sa20-Aug-16 13:05
Memberahmed_sa20-Aug-16 13:05 
I need to make multiple insert to multiple table have relation with each other

all id in all table is identity and already do model relation ef to it

in visual studio 2015

what i need actually when user click submit

Save the following data

Name,Email,Salary,DistrictId in table Employee

EmployeeId,CourseId in table EmployeeCourse

EmployeeId,LanaguageId,LevelId in table EmployeeLangage

what i write in create function in empcourse controller

my custom model as following
[code]

public class Customemployee
{
public string Name { get; set; }
public string Salary { get; set; }

public string Email { get; set; }
public int DistrictId { get; set; }

public List<empcourse> Courses { get; set; }
public List<emplangauge> Langs { get; set; }
}
public class Empcourse
{
public int Id { get; set; }
public int EmployeeId { get; set; }
public int CourseId { get; set; }
}
public class Emplangauge
{
public int Id { get; set; }

public int LevelId { get; set; }
public int LanguageId { get; set; }

}

}
[/code]
my controller empcourse is
[code]
public class empcourseController : Controller
{
mycourseEntities db = new mycourseEntities();
// GET: empcourse
public ActionResult Index()
{
return View();
}
public ActionResult Create()
{
ViewBag.CountryId = new SelectList(db.Countries.ToList(), "Id", "CountryName");
ViewBag.LanaguageId = new SelectList(db.Languages.ToList(), "Id", "LnaguageName");
ViewBag.LevelId = new SelectList(db.Levels.ToList(), "Id", "LevelName");
ViewBag.CourseId = new SelectList(db.Courses.ToList(), "Id", "CourseName");
return View();
}
[HttpPost]
public ActionResult Create(Customemployee cemp)
{
return View();
}
public JsonResult getcitybyid(int id)
{
db.Configuration.ProxyCreationEnabled = false;
return Json(db.Cities.Where(a => a.CountryId == id), JsonRequestBehavior.AllowGet);
}
public JsonResult getdistrictbyid(int id)
{
db.Configuration.ProxyCreationEnabled = false;
return Json(db.Destricts.Where(a => a.CityId == id), JsonRequestBehavior.AllowGet);
}
}
}

[/code]
my Create view is
[code]
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Create</title>
    <script src="~/scripts/jquery-1.10.2.js"></script>
    <script>
        $(function () {
            $("#CountryId").change(function () {
                $("#citylist").empty();
             //  alert("error");
                var x = $(this).val();
                $.ajax({
                    url: "/empcourse/getcitybyid",
                    data: { id: x },
                    success:function(res)
                    {
                        $.each(res, function (i, e) {
                            $("#citylist").append("<option value='" + e.Id + "'>" + e.CityName + "<option>")

                        });
                    }
                });


            });
            $("#citylist").change(function () {
                $("#districtlist").empty();
                // alert("error");
                var y = $(this).val();
                $.ajax({
                    url: "/empcourse/getdistrictbyid",
                    data: { id: y },
                    success: function (res) {
                        $.each(res, function (i, e) {
                            $("#districtlist").append("<option value='" + e.Id + "'>" + e.DistrictName + "<option>")

                        });
                    }
                });


            });
            $("#CourseId").change(function () {
                var index = 0;
                var id = $(this).val();
                var txt = $("#CourseId option:selected").text();
                $("#tb").append("<tr><td><input type = 'hidden' name='Courses[" + index + "].CourseId' value='" + id + "'/></td><td>" + txt + "</td><td><input type='button' value='remove' class='r'</td></tr>")

                index++;
            });
            $("#tb").on("click", ".r", function () {
                $(this).parent().parent().hide();
                $(this).parent().prev().prev().find("input").val("0");
            });
            $("#LanaguageId").change(function () {
                var index1 = 0;
                var id1 = $(this).val();
                var txt1 = $("#LanaguageId option:selected").text();
                $("#tb1").append("<tr><td><input type = 'hidden' name='Langs[" + index1 + "].LanguageId' value='" + id1 + "'/></td><td>" + txt1 + "</td><td><input type='button' value='remove' class='s'</td></tr>")

                index1++;
            });
            $("#tb1").on("click", ".s", function () {
                $(this).parent().parent().hide();
                $(this).parent().prev().prev().find("input").val("0");
            });

            $("#LevelId").change(function () {
                var index2 = 0;
                var id2 = $(this).val();
                var txt2 = $("#LevelId option:selected").text();
                $("#tb2").append("<tr><td><input type = 'hidden' name='Langs[" + index2 + "].LevelId' value='" + id2 + "'/></td><td>" + txt2 + "</td><td><input type='button' value='remove' class='y'</td></tr>")

                index2++;
            });
            $("#tb2").on("click", ".y", function () {
                $(this).parent().parent().hide();
                $(this).parent().prev().prev().find("input").val("0");
            });
        });
    </script>
</head>
<body>
    <div>
        @using (Html.BeginForm())
        {
            <div>
                Name:@Html.TextBoxFor(a=>a.Name)
                <br />
                Salary:@Html.TextBoxFor(a => a.Salary)
                <br />
                Email:@Html.TextBoxFor(a => a.Email)
                <br />
                Country:@Html.DropDownList("CountryId")
                <br />
                City:<select id="citylist" name="CityId"></select>
                <br />
                District:<select id="districtlist" name="DistrictId"></select>
                <br />
                Courses:@Html.DropDownList("CourseId")
                <br />
                <br />

                <table id="tb"></table>
                <br />
                <br />

                Language:@Html.DropDownList("LanaguageId")
                <br />
                <br />

                <table id="tb1"></table>
                <br />
                <br />

                Level:@Html.DropDownList("LevelId")
                <br />
                <br />

                <table id="tb2"></table>
                <br />
                <input type="submit" />
            </div>
        }
    </div>
</body>
</html>

[/code]
my interface and Relation diagram found in this link
http://www.mediafire.com/view/mn44bl69zkrjukp/Interface3.jpg
AnswerRe: add data to more table relation in same time Pin
ahmed_sa21-Aug-16 6:11
Memberahmed_sa21-Aug-16 6:11 
Questionweb form message using master pages message and/or JavaScript message Pin
dcof18-Aug-16 13:07
Memberdcof18-Aug-16 13:07 
AnswerRe: web form message using master pages message and/or JavaScript message Pin
John C Rayan19-Aug-16 3:24
professionalJohn C Rayan19-Aug-16 3:24 
GeneralRe: web form message using master pages message and/or JavaScript message Pin
dcof19-Aug-16 10:30
Memberdcof19-Aug-16 10:30 
GeneralRe: web form message using master pages message and/or JavaScript message Pin
John C Rayan21-Aug-16 23:16
professionalJohn C Rayan21-Aug-16 23:16 
Questionweb form using javacript Pin
dcof17-Aug-16 17:16
Memberdcof17-Aug-16 17:16 
AnswerRe: web form using javacript Pin
Peter Leow17-Aug-16 17:49
professionalPeter Leow17-Aug-16 17:49 
AnswerRe: web form using javacript Pin
F-ES Sitecore17-Aug-16 23:48
mveF-ES Sitecore17-Aug-16 23:48 
RantRe: web form using javacript Pin
Richard Deeming18-Aug-16 2:48
mveRichard Deeming18-Aug-16 2:48 
GeneralRe: web form using javacript Pin
Richard MacCutchan18-Aug-16 3:34
mveRichard MacCutchan18-Aug-16 3:34 
AnswerRe: web form using javacript Pin
Richard MacCutchan18-Aug-16 3:32
mveRichard MacCutchan18-Aug-16 3:32 
QuestionHow to create a Join, or place a datatable within a datatable for ReportViewer Pin
jkirkerx17-Aug-16 8:38
professionaljkirkerx17-Aug-16 8:38 
Questionhow to encrypt and decrypt the file through pkcs Pin
Member 1268779016-Aug-16 0:42
MemberMember 1268779016-Aug-16 0:42 
AnswerRe: how to encrypt and decrypt the file through pkcs Pin
Kornfeld Eliyahu Peter16-Aug-16 3:25
professionalKornfeld Eliyahu Peter16-Aug-16 3:25 
QuestionVS2012 cannot open MVC4 application - the system cannot find the file specified (exception from HRESULT 0x80070002) Pin
Usman ali15-Aug-16 20:37
MemberUsman ali15-Aug-16 20:37 
SuggestionRe: VS2012 cannot open MVC4 application - the system cannot find the file specified (exception from HRESULT 0x80070002) Pin
Richard MacCutchan15-Aug-16 22:28
mveRichard MacCutchan15-Aug-16 22:28 
GeneralRe: VS2012 cannot open MVC4 application - the system cannot find the file specified (exception from HRESULT 0x80070002) Pin
Usman ali15-Aug-16 22:57
MemberUsman ali15-Aug-16 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.