I am trying to use the Razor framework within an ASP.NET Core project (.NETCoreApp 1.1), however, after retrieving the package from Nuget, the reference is not recognized by VS.

Reference error

I'm rather unfamiliar with the framework, is there something I am missing ? All Razor MVC generated pages work, although they are not recognized as so by Visual Studio. Hence the following happens: Intellisense error

Can you please help me solve this issue?

I have this code in razor

@{
    var aid = new List<int>();
    foreach (var item in Model.applications)
    {
        if (item.Status == 1)
        {
            aid.Add(item.Id);
        }
    }
}

and in js I have this:

<script>
function checkIfSigned() {

    var data = { aid: @aid };
    console.log(data);

    $.ajax({
        url: '@Url.Action("Method", "Controller")',
        type: "POST",
        data: data,
        ...
    });
}

and in my controller:

public JsonResult Method(List<int> aid)
{
  foreach (var item in aid)
  { ... }
}

my problem is:

var data = { aid: @aid };

It throws an exception:

Uncaught SyntaxError: Unterminated template literal

var data = { aid: System.Collections.Generic.List`1[System.Int32] };

What can I do? how can I post list?

I am getting an error in my razor layout that I think is really a result of my lack of knowledge and exposing a design flaw.

What I have is a tabbed page. On a tab I have a grid. I also have a create button to create a new record.

PREVIOUSLY everything loads fine except that clicking new record jumps from the tabbed parent and is at the "top level".

What I want is to display the grid under it's correct tab AND clicking add new ALSO loads under the current tab.

So I thought to use render section and have been running into errors that I believe ultimately are the result of poor design.

So my question is how do I get the grid and the "new record" to display under the "parent tab page"?

Currently this is my layout that errors at runtime:

LoadTabs.cshtml

<div>
   <ul class="nav nav-tabs">
      @Html.RenderBootstrapTabHeader("tab-clients", "Clients", true)
      @Html.RenderBootstrapTabHeader("tab-scopes", "Scopes")
      @Html.RenderBootstrapTabHeader("tab-users", "Users")
   </ul>
   <div class="tab-content">
      @Html.RenderBootstrapTabContent("tab-clients", @TabClients(), true)
      @Html.RenderBootstrapTabContent("tab-scopes", @TabScopes())
      @Html.RenderBootstrapTabContent("tab-users", @TabUsers())
   </div>
</div>


@helper TabClients()
{
   Html.RenderAction("LoadClients", "ClientConfiguration");
}

@helper TabScopes()
{...}

@helper TabUsers()
{...}

ClientConfig.cshtml

@*Create Button*@
 <a href="#" onclick="@RenderSection("CreateEdit")">
        New Record
 </a>

//This is how I am trying to make the grid the default section
@RenderSection("DisplayList")


@helper CreateEdit()
{....Create HTML...}


@helper DisplayList()
{...Grid html...}

Finally in case my design is acceptable here is the error message I am getting:

The file "~/.../ClientConfig.cshtml" cannot be requested directly because it calls the "RenderSection" method.

Which of course has answers on SO here and here leading me to suspect design flaw.

I am using CKEditor in a web application in ASP.NET WebPages (Razor).

I spent a number of days trying to figure out how to make and integrate a basic file manager to support uploading images to CKEditor. The documentation in this area is next to useless. Nothing addressed the WebPages environment. Lots of PHP and WebForms and MVC, but nothing specifically for WebPages.

I finally figured out how to do it and am sharing it here.

CK Editor has an attribute that can be added to the .Replace which tells CKEditor to add an "Upload" tab (that had a built-in file browser) to the Image Properties panel:

                CKEDITOR.replace('editor1'
                , {
                    filebrowserImageUploadUrl: 'imageUpload2'
                    }
                );

where "imageUpload2" was the name of the cshtml file (imageUpload2.cshtml) that contained the upload logic. Adding that filebrowserImageUploadUrl caused the CKEditor image properties panel to be modified to display (in the newly added "Upload" menu tab) a "Browse" button and a "Send to Server" button.

The "Browse" button activates CKEditor's Built-in file browser patterned after the html input filetype "file"; the "Send To Server" button executes the file manager you coded (see below).

The procedure would be for the user to:

  • click on the Insert Image icon in the CKEditor menu
  • Click on the "Upload" tab in the image properties dialog
  • Click on the "Browse" button to browse folders on the client machine and select ("Open") the desired image file
  • Click on the "Send to Server" button to execute the file manager's code (imageUpload2.cshtml), saving the image file to the folder specified in the cshtml file and passing the url of the file back to CKEditor.

The code in the file manager is minimal - no bells or whistles:

@{
Layout = null; 
var context=HttpContext.Current;
HttpPostedFile uploads = context.Request.Files["upload"];

//get full filename
string file = System.IO.Path.GetFileName(uploads.FileName);
//get extension (including the period)
string ext = System.IO.Path.GetExtension(uploads.FileName);

//CKEditorFuncNum is passed in from the image propoerties panel in CKEditor
string CKEditorFuncNum = context.Request["CKEditorFuncNum"];

//use whatever folder name you prefer - make sure it has read/write permissions on the server
string url = Href("~/imageUploads/" + file);
var message = " .jpg .jpeg .gif .png ".Contains(ext.ToLower())?"":ext+" is invalid file type";


//Save file if it is one of the allowable extensions
if(String.IsNullOrEmpty(message))
{
    uploads.SaveAs(context.Server.MapPath(".") + url );
}

//create return javascript to CKEditor (must have <script></script> tags)
var responseFormat = "<script>window.parent.CKEDITOR.tools.callFunction({0}, \"{1}\", \"{2}\");</script>";
var responseText = String.Format(responseFormat, CKEditorFuncNum,   url, message);

//send script back to CKEditor image properties popup and close this page
context.Response.Write(responseText);
context.Response.End();            
}

I hope this saves someone else the time I wasted trying to figure out what worked.

Within my application the user will login, after they login I need to somehow keep track of the session that they have just created. Once they log in they have two options, enter the building and be done with the login process or check out equipment for their session. I need to keep track of that session within the application for the item check out. But I do not want to have to pass the current session model throughout each view before the equipment view? Currently I am using TempData, but I feel like this is playing with fire as I read somewhere temp data is cleared after two redirects I believe? Is there a permanent temp data or something else I can use that is safer? Thanks for the help.

So I have this kind of logic where @1 in the query is i from the for loop

for (var i = 1; i <= 12; i++) {

    var getPR = "SELECT top 1 kg, rep, date FROM Test WHERE exerVariName = @0 AND rep = @1 order by kg desc"; 

    foreach (var c in query stuff) {
        // Display both results and 0 if no result
    }
}

So the database is setup in such a way that a kilogram value is entered (kg) along with a number of sets and reps as well as a name of the exercise and a date. The query will look though each exercise name, and see where the highest kilogram is for each rep between 1-12, so for exercise number one, check highest kilogram for rep 1, then 2 and so on, then next exercise and from 1-12, however, there isn't always a result that is matched if for example a certain exercise is not in the database with 5 repetitions set to it, so it would jump that and go to 6 and check again.

What I would like is that if there is no match from the database, set c.kg to 0 in the foreach so that there is still a value there, because I want to set up a html table with 12 rows and I want something in all of them, can this be done?

Using razor (cshtml), not MVC, and SQL server compact edition.

My code:

<table class="prTable">
        <tr>
            <th>Exercise</th>
            <th>1</th>
            <th>2</th>
            <th>3</th>
            <th>4</th>
            <th>5</th>
            <th>6</th>
            <th>7</th>
            <th>8</th>
            <th>9</th>
            <th>10</th>
            <th>11</th>
            <th>12</th>
        </tr>
    <!-- Loops out all the different exercise names for deadlifts -->
    @foreach (var d in db.Query(getVariD))
    {
        <tr class="prTableRow">

            <td class="prExerVariNameTD">@d.exerVariName</td>
            @* Gives me a result from each rep range, var i goes from 1 up to choosen rep, and puts
                that into the sql string to get each rep range. *@
            @for (var i = 1; i <= 12; i++)
            {
                //Selects the row with the highest weight from each exercise AND from each rep range
                //up to choosen value in the for loop.
                var getPR = "SELECT top 1 kg, rep, date FROM Test WHERE exerVariName = @0 AND rep = @1 order by kg desc";
                //Loops out the database values.
                foreach (var c in db.Query(getPR, d.exerVariName, i))
                {

                    DateTime Date = c.date;
                    var finalDate = "- " + Date.ToString("MMM dd, yyyy");
                    var weight = c.kg + "kg";
                    var rep = "x " + c.rep;

                    <td class="prTableCell" title="@finalDate">@weight</td>
                }
            }
        </tr>
    }
</table>

I am working on a small app to store and display fees.

The app is fairly simple with Members hasmany Fees. Fees can also have FeeTypes.

I am having an issue with displaying associated records via razor syntax.

I need to display the FeeTypeName based on the FeeTypesId in the Fees table but I seem to be hitting a wall. The foreign key is FeeTypesId and corresponds to the PK Id on FeeTypes.

Am I going about this all wrong? I don't want to query every record as Fees already stores the Id just fine. Models:

public class Members
{
    [Key]
    public int MemberNo { get; set; }
    [Display(Name = "First Name")]
    public string FirstName { get; set; }
    [Display(Name = "Middle Name")]
    public string MiddleName { get; set; }
    [Display(Name = "Surname")]
    public string Surname { get; set; }
    [DataType(DataType.EmailAddress, ErrorMessage = "Invalid Email Address")]
    [Display(Name = "Primary Contact Email")]
    public string MemberPrimaryContactEmail { get; set; }
    [Display(Name = "Member Status")]
    public MemberStatus MemberStatus { get; set; }

    [Display(Name = "Member Fees")]
    public virtual ICollection<Fees> Fees { get; set; }

    [Display(Name = "Member FUM")]
    public float? MemberFUM { get; set; }
    public string MemberWCName { get; set; }
    public string MemberAdviceOSName { get; set; }
    public string MemberRevexName { get; set; }
    [Display(Name = "Accounting Firm")]
    public virtual Accountants AccountantNo { get; set; }
    [Display(Name = "Adviser Name")]
    public virtual Adviser Adviser { get; set; }
    [Display(Name = "Head Company")]
    public virtual HeadCompany HeadCompany { get; set; }
    public DateTime? Created_Date { get; set; }
    public string Created_By { get; set; }
    public DateTime? Modified_Date { get; set; }
    public string Modified_By { get; set; }



}    




public class Fees
{
    [Key]
    public int FeeNo { get; set; }
    public FeeTypes FeeType { get; set; }
    [Display(Name = "Fee Type")]
    public int FeeTypesId { get; set; }
    [Display(Name = "Frequency of Fee")]
    public FeeOccurence FeeOccurence { get; set; }
    [Display(Name = "Fee Amount")]
    public float FeeAmount { get; set; }
    [Display(Name = "Fee Status")]
    public FeeStatus FeeStatus { get; set; }
    [Display(Name = "Date received (for billing)")]
    [DataType(DataType.Date)]
    [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
    public DateTime? FeeDate { get; set; }
    public virtual Members Members { get; set; }
    public int MemberNo { get; set; }
    public DateTime? Created_Date { get; set; }
    public string Created_By { get; set; }
    public DateTime? Modified_Date { get; set; }
    public string Modified_By { get; set; }

}

public class FeeTypes
{
    public int Id { get; set; }
    [Display(Name = "Fee Name")]
    public string FeeTypeName { get; set; }



}

Controller - Where I am trying to display FeeTypeName

    public ActionResult Details(int? id)
    {
        if (id == null)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Members members = db.Members.Find(id);
        ViewBag.Fees = db.Fees.Where(x => x.Members.MemberNo.Equals(x.MemberNo));
        ViewBag.FeeTypesId = new SelectList(db.FeeTypes, "Id", "FeeTypeName");


        if (members == null)
        {
            return HttpNotFound();
        }
        return View(members);
    }

And the view

    @model AccPortal.Models.Members

    @{
        ViewBag.Title = "Details";
    }
                @{ int i = 0; }
                @foreach (var item in Model.Fees)
                {


                    <tr data-id="@i">
                        @Html.HiddenFor(model => model.Fees.ElementAt(i).FeeNo, new { @class = "md-fee-value", name = "md-fee-id", data_type = "testid", id = "testid" })
                        <td class="md-fee-value" data-type="date">@String.Format("{0:d}", item.FeeDate)</td>
                        <td class="md-fee-value" data-type="type">@item.FeeOccurence</td>
//NEED TO DISPLAY FeeTypeName here instead of FeeTypesId
                        <td class="md-fee-value" data-type="type">@item.FeeTypesId</td>
                        <td class="md-fee-value" data-type="status">@item.FeeStatus</td>
                        <td class="md-fee-value" data-type="amount">@item.FeeAmount</td>
                        <td>
                            <button type="button" class="md-button md-button--edit" title="edit">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                            </button>
                            <button type="button" class="md-button md-button--remove" title="remove">
                                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                            </button>
                        </td>
                    </tr>
                    i++;
                }

I am trying to display an icon after a text box within a form-horizontal Bootstrap form. So I set my text-box width to 80% and added the icon.

<div class="form-group">
        @Html.LabelFor(model => model.Tag, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.Tag, new { htmlAttributes = new { @class = "form-control", style = "width: 80%" } })
        <img id="tag-status" src="~/Content/Images/alert.png" style="display: inline" />
        @Html.ValidationMessageFor(model => model.Tag, "", new { @class = "text-danger" })
</div>

Unfortunately, this places the icon below the text box.

enter image description here

Looking further, I see that the form-control class includes display: block. If I remove that, it displays how I want.

enter image description here

But I'm concerned that removing the block style may cause display issues on some devices.

Does anyone know if there's there a Bootstrap way to do what I want?

I am trying to make my code able to run multiple queries at the same time, but as devart havent implemented await / async, I have a some issues figuring out how to make it work properly

My first idea was to just wrap my repository calls with

public Task SleepAsync(int millisecondsTimeout)
{
    return Task.Run(() => Sleep(millisecondsTimeout));
}

But from https://blogs.msdn.microsoft.com/pfxteam/2012/03/24/should-i-expose-asynchronous-wrappers-for-synchronous-methods/ that sounds like a bad idea and dont really achieve anything

So I have been looking at the async functionality Devart has in the driver https://www.devart.com/dotconnect/oracle/articles/asynchronous.html

The problem is that I cant figure out how to use this BeginExecuteReader and EndExecuteReader with Dapper, I end up with something like

await Task.Factory.FromAsync(sqlConnection.BeginOpen, sqlConnection.EndOpen, null);
var oracleCommand = new OracleCommand(sql, sqlConnection);

OracleDataReader result = await Task.Factory.FromAsync(oracleCommand.BeginExecuteReader, oracleCommand.EndExecuteReader, null);

So I end up with OracleDataReader where normally I would end up with IEnumerable using:

IEnumerable<TModel> elements = await sqlConnection.QueryAsync<TModel>(sql, parameters);

What I have tried first is just write it using Dapper

protected async Task GetElement(string sql, object parameters = null)

{
    using (var sqlConnection = new OracleConnection(Connectionstring))
    {
        await sqlConnection.OpenAsync();
        var element = await sqlConnection.QuerySingleAsync<TModel>(sql, parameters);

        return element;
    }
}

But that does not run async

Is it possible to keep using Dapper and make it really async?

I am trying to add anything in the query of the request to anchors in the html result:

Fictitious example:

User makes a request (note that band and song could be anything, I have a route catering this request: template: "{band}/{song}"):

http://mydomain/band/song?Param1=111&Param2=222

Now I want my anchors to append the query string part to the href of my anchors. So I tried something like this (note the 'asp-all-route-data'):

<a asp-controller="topic" asp-action="topic" asp-route-band="iron-maiden" asp-route-song="run-to-the-hills" asp-all-route-data="@Context.Request.Query.ToDictionary(d=>d.Key,d=>d.Value.ToString())">Iron Maiden - Run to the hills</a>

The append of the query string actually works with the above code but then the "iron-maiden" and "run-to-the-hills" are lost in the result. The above tag helper returns the following (note how the helper mirrors the band and song in the request into the href and not the band and song I specified in the asp-route attributes):

<a href="http://mydomain/band/song?Param1=111&Param2=2222">Iron Maiden - Run to the hills</a>

I expect the following result from the helper:

<a href="http://mydomain/iron-maiden/run-to-the-hills?Param1=111&Param2=2222">Iron Maiden - Run to the hills</a>

It seems like when I use the asp-all-route-data I loose the asp-route-band and asp-route-song values in the result.

Has anybody ever stumbled across this?

Thanks

Hooroo

I am using VS 2013, i am developing MVC website, also published in azure. Now i am facing the problem in remote debugging, while remote debugging i am not able to hit the breakpoint in cshtml file. how to have breakpoint hit in cshtml files?

I am building a very basic "dice cricket" simulator. I am trying to track the completed innings and overs as well as the scores using integers and lists that I am storing in the asp.net Session.

I have an "innsOver" class representing a set of 6 deliveries, with an integer for each delivery representing the outcome of the ball.

public class innsOver
{
public int overNumber { get; set; }
public int ball1 { get; set; }
public int ball2 { get; set; }
public int ball3 { get; set; }
public int ball4 { get; set; }
public int ball5 { get; set; }
public int ball6 { get; set; }
}

I also have 2 Lists based on this class, to represent 2 innings:

List<innsOver> inns1 = new List<innsOver>();
List<innsOver> inns2 = new List<innsOver>();

I have also declared integers for the number of complete inns (so I know whether I am playing inns1 or inns 2) and the number of complete overs (so i know how many overs are bowled). These are

int oversComplete = 0;
int innsComplete = 0;

The 2 integers oversComplete and innsComplete and the 2 lists inns1 and inns2 are declared globally.

The "over" is played by pressing a button, which calls the playOver() method which itself calls a bowlDelivery() method. When the playOver() method is completed it should increment the completeOvers integer, add the completed over to the appropriate innnings list (inns1 or inns2) and return that to a gridView.

public void bowlOver()
{
    //other processing checks which end the over is bowled from
   //which batsman is the striker / non-striker and who is bowling.

    for (int i = 1; i <7; i++)
    {
        int x = bowlDelivery();
        int b = 0;
        if (x == 5)
        {
            //this represents a chance of a wicket that was 
            //unsuccessful so no run scored
            b = 0;
        }
        else if (x == 7)
        {
            //this means a wicket fell so i have wicket processing;
        }
        else if (x == 1 || x == 3)
        {
            b = x;
            //award 1 run & change striking batsman
        }
        else
        {
            b = x;
           //2, 4 or 6 runs awarded
        }
        //the outcome is returned to the correct ball
        switch (i)
        {
            case 1:
                activeOver.ball1 = b;
                break;
            case 2:
                activeOver.ball2 = b;
                break;
            case 3:
                activeOver.ball3 = b;
                break;
            case 4:
                activeOver.ball4 = b;
                break;
            case 5:
                activeOver.ball5 = b;
                break;
            case 6:
                activeOver.ball6 = b;
                break;
        }

    }
    //the over result is returned to the correct inns list
    switch (innsComplete)
    {
        case 0:
            Session["inns1"] = inns1;
            Session["oversComplete"] = oversComplete;
            oversComplete = (int)Session["oversComplete"];
            activeOver.overNumber = oversComplete + 1;
            oversComplete = activeOver.overNumber;
            inns1 = (List<innsOver>)Session["inns1"];
            inns1.Add(activeOver);
            GridView3.DataSource = inns1;
            GridView3.DataBind();
            Session["inns1"] = inns1;
            Session["oversComplete"] = oversComplete;
            break;
        case 1:
            Session["inns2"] = inns2;
            Session["oversComplete"] = oversComplete;
            oversComplete = (int)Session["oversComplete"];
            activeOver.overNumber = oversComplete + 1;
            oversComplete = activeOver.overNumber;
            inns2 = (List<innsOver>)Session["inns2"];
            inns2.Add(activeOver);
            GridView3.DataSource = inns2;
            GridView3.DataBind();
            Session["inns2"] = inns2;
            Session["oversComplete"] = oversComplete;
            break;
    }
}

public int bowlDelivery()
{
   //currently the result of each ball is completely random but i will add weighting later
    int x = rnd.Next(1, 7);
    if (x == 5)
    {
        int y = rnd.Next(1, 6);
        if(y > 4)
        {
            x = 7;
        }
        else
        {
            x = 5;
        }
    }
    return x;
}

However, at the moment I only ever get a single over returned, and the overNumber is always "1". The ball values change, so it just seems to be playing the 1st over repeatedly. I'm expecting (trying to achieve) the over overNumber incrementing and additional rows being added to the innsX list displayed in the gridview.

Any suggestions of what I have wrong?

I have setup a getJSON call when page loads in my .NET MVC app like this:

$(document).ready(function(){
   $.getJSON("/Administrator/GetAllUsers", function (res) {

            // getting internal server error here...
        });

});

And the action looks like this:

  [HttpGet]
    [ActionName("GetAllUsers")]
    public string GetAllUsers()
    {
        return new JavaScriptSerializer().Serialize(ctx.zsp_select_allusers().ToList());
    }

I'm getting this error:

500 (Internal Server Error)

What am I doing wrong here???

I am trying to use the Razor framework within an ASP.NET Core project (.NETCoreApp 1.1), however, after retrieving the package from Nuget, the reference is not recognized by VS.

Reference error

I'm rather unfamiliar with the framework, is there something I am missing ? All Razor MVC generated pages work, although they are not recognized as so by Visual Studio. Hence the following happens: Intellisense error

Can you please help me solve this issue?

I am trying to develop simple Registration form and login form. if a user forgot his/her password then he clicks on forgot password button and a forgot password page opens where he will provide his/her email address and a password reset link is send to his/her mail address.Then he/she will click on the reset password and he will redirected to changePassword.aspx page but i am stuck with here. when i click on reset password link i got the following error..Please find images in attachments This the error i got

Here is the code for password reset

protected void SetPasswordResetEmail(string UserName, string ToEmail, string UniqueId)
    {
        MailMessage message = new MailMessage("email@gmail.com", ToEmail);
        StringBuilder sbEmailBody = new StringBuilder();
        sbEmailBody.Append("Dear" + UserName + ",<br/><br/>");
        sbEmailBody.Append("Please click the following link to reset your password");
        sbEmailBody.Append("<br/>");           sbEmailBody.Append("http://localhost/BootstrapLogin/ChangePassword.aspx?uid=" + UniqueId);
        message.IsBodyHtml = true;
        message.Body = sbEmailBody.ToString();
        message.Subject = "Reset Your Password";
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.EnableSsl = true;
        NetworkCredential NetworkCred = new NetworkCredential("email@gmail.com", "password");
        smtp.UseDefaultCredentials = true;
        smtp.Credentials = NetworkCred;
        smtp.Port = 587;
        smtp.Send(message);


    }

I'm currently trying to call a javascript function by a form inside cshtml file. There would be a textbox in the form that receive string from the user and 'Send' button which send the string to the javascript function.

Script for the form:

@using (Html.BeginForm("SearchStreet", "CustomerInformation", FormMethod.Get, new { @class = "form-inline" }))
{
    <input type="hidden" name="CustId" value="@ViewBag.CustId" />
    <input type="hidden" name="AddressId" value="@ViewBag.AddressId" />

    <div class="form-group">
        <label for="street">Street Name</label>
        @Html.TextBox("street", null, htmlAttributes: new { @class = "form-control" })
    </div>

    <div class="form-group">
        <label></label>
        <input type="submit" value="Send" class="form-control btn btn-default" />
    </div>
}

How to send the string to the specific Javascript function? Thanks.

I have a MainView "About.cshtml" it has a script tag in it and a partial view.

<script>
    $(function () {}
</script>
<div>
    @Html.Partial("~/Views/Maps/_MapDetailsList.cshtml", Model.saVM)
</div>

Inside "_MapDetailList.cshtml" partial view i am referencing another script ge.js

@Scripts.Render("~/Scripts/ge.js")
<table id="MapDetails">
      .....
  <tr><th>
    <script>setGrowthArray(1, 1);</script>
  </th></tr>
</table>

ge.js

var dictionaryGrowth = new Array();

function setGrowthArray(colIndex, mapDetailId) {
//making a sparse array
dictionaryGrowth[colIndex] = mapDetailId;
}

Now i want to send this dictionaryGrowth array to server side after the page/table is loaded

so i did the following in the About.cshtml script but didnot work..

<script>
    $(function () {
   $("#MapDetails").load(function () { alert("everything seems fine");});
  }
</script>

Also please tell me what will be the script and DOM loading sequence in my case.

UPDATE

Inside About.cshtml script tag

 <script>
    $(function () {

    var url = '@Url.Action("CalculateGrowth", "Maps")';
    $.post(url, {growth:dictionaryGrowth}, function(data){alert(data);});
});
</script>

It says Uncaught ReferenceError: dictionaryGrowth is not defined..

This Query Return Several Record And I Show Result In a Grid I want Show All Record in a Record With Multi Column

select  Acceptor.Terminal, Acceptor.AcceptorName 
            ,Em.CauseDamage, Em.DescriptionDamage                                        
            from Em  
            left outer join Acceptor on Acceptor.Terminal = Em.Terminal 
            where     (Acceptor.Terminal = '70460440')



Terminal  AcceptorName CauseDamage   DescriptionDamage
-------------------------------------------------------
70460440  Alvin        reason1       Comments1
70460440  Alvin        reason2       Comments2
70460440  Alvin        reason3       Comments3

I Want Show Result In grid

Terminal  AcceptorName  CauseDamage1   DescriptionDamage1 CauseDamage2  DescriptionDamage2  CauseDamage3   DescriptionDamage3
--------------------------------------------------------------------------------------------------------------------
70460440  Alvin         reason1       Comments1           reason2       Comments2           reason3        Comments3   

<a id='aApp' runat='server' title='Approve' onclick='return OpenAppWin("<%#Eval("ID1") %>",
"<%#Eval("ID2") %>","<%#Eval("NAME") %>")' class='label' href='#'>Approve</a>

I need to pass 3 parameters as querystring to iframe, reason I am using runat='server' with anchor is to show user they can't click this link until they submit "remarks" which I am doing at server side i.e. disable link. Onclick I get this error Please advice any alternative or how to fix this error ?

I have a login function on my site which works as intended, but when a user logs in, I want to re-render the navbar at the top of my side only (remove the login button, add logout button etc). I want to do this, without the rest of the page refreshing, seeing as a lot of my views get data from ajax, and a refresh of the page forces the user to load the ajax again, which I want to avoid.

I have defined the following in a partial view:

<div class="header">
<nav class="navbar navbar-site navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button data-target="#main_menu" data-toggle="collapse" class="navbar-toggle" type="button">
                <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
            </button>
            <a href="@Url.Action("Index", "Home", new {area = ""})" class="navbar-brand logo logo-title">
                <!-- Original Logo will be placed here -->
                ESport<span>Foundation  | </span>BETA
            </a>
        </div>
        @if (ViewBag.User == null)
        {
            <div class="navbar-collapse collapse" id="main_menu">

                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#loginModal" data-toggle="modal">Login</a></li>
                    <li><a href="#">@Language.Signup</a></li>
                    <li class="postadd">
                        @Html.ActionLink("BLIV COACH", "EditCoach", "Account", null, new { @Class = "btn btn-block   btn-border btn-post btn-danger", style = "padding: 12px 0px" })
                    </li>
                </ul>
            </div>
        }
        else
        {
            <div class="navbar-collapse collapse" id="main_menu">

                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown">Welcome, @ViewBag.User.FirstName @ViewBag.User.LastName <i class="fa fa-angle-down"></i></a>
                        <ul class="dropdown-menu">
                            <li>Dashboard</li>
                        </ul>
                    </li>
                    <li>@Html.ActionLink("Logout", "Logout", "Account", new { area = "" }, null)</li>
                    <li class="postadd">
                        @Html.ActionLink("BLIV COACH", "EditCoach", "Account", null, new { @Class = "btn btn-block   btn-border btn-post btn-danger", style = "padding: 12px 0px" })
                    </li>
                </ul>
            </div>
        }
        <!--/.nav-collapse -->
    </div>
    <!-- /.container-fluid -->
</nav>

<!-- Login Modal -->
<div id="loginModal" class="modal fade" role="dialog">
    <div class="modal-dialog modal-sm">

        <!-- Modal content-->
        <div class="modal-content login-modal">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title text-center">Log ind</h4>
            </div>
            <div class="modal-body">
                <div class="control-group login-modal-space">
                    <input class="decorative-input inspectletIgnore" id="signin_email" name="email" placeholder="Emailadresse" type="email">
                </div>
                <div class="control-group login-modal-space">
                    <input id="signin_password" name="email" placeholder="Password" type="password">
                </div>
                <div class="clearfix space">
                    <label for="remember_me" class="checkbox remember-me space" style="color: #494949; font-weight: normal">
                        <input type="checkbox" name="remember_me" id="remember_me" value="true" class="remember_me">
                        Husk mig
                    </label>
                    <a href="#" class="pull-right" data-from="email" style="margin-bottom: 10px; margin-top: 10px;">Har du glemt din adgangskode?</a>
                </div>
                <button type="submit" class="btn btn-block btn-xl btn-primary btn-large" id="user-login-btn" style="font-size: 16px">
                    Log ind
                </button>
            </div>
            <div class="modal-footer">
                <div class="clearfix">
                    <p class="pull-left" style="margin-bottom: 10px; margin-top: 10px;">Har du ikke en konto?</p>
                    <a href="#" class="btn btn-primary-dark pull-right">Tilmeld dig</a>
                </div>
            </div>
        </div>

    </div>
</div>

This is rendered in the layout file, but how do I re-render ONLY this partial when a user logs in ?

I am working on an ASP.net MVC website with Identity for security and login. I more or less know the basics of working with ASP.net Identity but a problem I have is that I have no idea of how it access the database form the connection-string.

To clarify my question: how does ASP.net Identity access the database and should I use the same method?