I am using MVC 5 with Identity 2. I have created two roles, one for administrators, and one for vendors. The problem I have is that the registration form must use properties that are defined in the vendor role. I cannot figure out how to make MVC use those role properties for register purposes. I've tried assigning the appropriate role to the applicationuser but, after assigning it the role it still says it doesn't exist. Is there anyway of doing this, or am I going to have to split this into two register screens (ie one to handle initial user creation and a second one to handle role specific implementation)?

Thanks in advance.

        public async Task<ActionResult> Register(RegisterVendorViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName = model.Email, 
                    Email = model.Email,
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    PhoneNumber = model.PhoneNumber,
                    CompanyName = model.CompanyName,
                    Address = model.Address,
                    City = model.City,
                    State = model.State,
                    PostalCode = model.PostalCode
                };
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)

I am trying to display a date as dd/MM/yyyy, but it keeps showing as MM/dd/yyyy in the view.

Model:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
[Required]
public DateTime? HireDate { get; set; }

View:

@Html.DisplayFor(modelItem => item.HireDate)

I am trying to change how I post and update my primary class JOB. Previously I was using the Customer Class as a List and I was storing the JOB Customer information in the Job class itself. The problem with this was If I went to go update a Customers information in the Customer List I would have to go to every Job that has that Customer and Manually update everyone separately. So I am unsure how to do this. When I am creating a New Job how do I Connect the appropriate Customer with that Job? I am already doing this with another class called ChangeOrder but the difference is the Job has to be already been created before I can make that Post.. And also, the Customer can be assigned to multiple Jobs. So How does the foreign key work with this? How can you have a Customer with multiple foreign keys "JobIds" attached to it?

Job

public List<Job> PostNewJob(Job newJob)
    {
        Job job = new Job();

        job.JobId = newJob.JobId;
        job.JobNumber = newJob.JobNumber;
        job.JobName = newJob.JobName;
        job.JobDescription = newJob.JobDescription;

        db.Jobs.Add(newJob);
        db.SaveChanges();

        return db.Jobs.ToList();
    }

 public class Job
   {
    public Job()
    {
        this.Customers = new HashSet<Customer>();
        this.ChangeOrders = new HashSet<ChangeOrder>();
    }
    public int JobId { get; set; }
    public int JobNumber { get; set; }
    public string JobName { get; set; }
    public string JobDescription { get; set; }

    public virtual ICollection<Customer> Customers { get; set; }
    public virtual ICollection<ChangeOrder> ChangeOrders { get; set; }
}

Customer

public List<Customer> PostNewCustomer(Customer newCustomer)
    {
        Customer customer = new Customer();

        customer.CustomerId = newCustomer.CustomerId;
        customer.CustomerName = newCustomer.CustomerName;
        customer.CustomerPhoneNumber = newCustomer.CustomerPhoneNumber;
        customer.CustomerFaxNumber = newCustomer.CustomerFaxNumber;
        customer.JobId = newCustomer.JobId;

        db.Customers.Add(newCustomer);
        db.SaveChanges();

        return db.Customers.ToList();
    }

 public class Customer
  {

    public int CustomerId { get; set; }
    public string CustomerName { get; set; }
    public Int64 CustomerPhoneNumber { get; set; }
    public Int64 CustomerFaxNumber { get; set; }

    public int? JobId { get; set; }
}

Angular Controller

 $scope.submitJob = function () {
    var id = $scope.currentItem.JobName
    var data = {
        JobId: $scope.currentItem.JobId,
        JobNumber: $scope.currentItem.JobNumber,
        JobName: $scope.currentItem.JobName,
        JobDescription: $scope.currentItem.JobDescription


    }
    $http.post('/api/apiJob/PostNewJob', data).success(function (data, status, headers) {
        console.log(data);
           $scope.PrintPreviewModal();
           window.top.location.reload();

    });
 };

View

  <form ng-submit="submitJob()" enctype="multipart/form-data">
                        <fieldset>
                            <div>
                                <div class="inline-fields">
                                    <label>Number:</label>
                                    <input ng-model="currentItem.JobNumber" type="text">

                                    <label>Job Name:</label>
                                    <input ng-model="currentItem.JobName" type="text">
                                    <label>Customer:</label>
                                    <input type="text" ng-model="currentItem.CustomerName">
                                </div>
                                <div class="inline-fields">
                                    <label>Address:</label>
                                    <input ng-model="currentItem.CustomerAddress" type="text">
                                </div>
                                <div class="inline-fields">
                                    <label>City:</label>
                                    <input ng-model="currentItem.CustomerCity" type="text">

                                    <label>St:</label>
                                    <input ng-model="currentItem.CustomerState" type="text">

                                    <label>Zip:</label>
                                    <input ng-model="currentItem.CustomerZipcode" type="text">

                            <input type="submit" value="Save" />

                        </fieldset>
                    </form>

I have a html table that i am running at the server level. However, i am having trouble accessing the data that it is being populated with.

I am populating the table using javascript but i need to access the data using vb.net.

I am using jquery to get the information to the page by using the .html method.

Here is my javascript,

function ShowProj(strId, qno,ar) {
        $('#hiddenQno').val(qno);
        $('#qnoLbl').val(qno);
        var output = '';
        output = "<tr><th>Product</th>";
        output += "<th>Bond</th>";
        output += "<th>Cut</th>";
        output += "<th>Pack</th>";
        output += "<th>Delivery date</th></tr>";
        for (i = 0; i < ar.length; i++) {
            output += "<tr>";
            output += "<td style='width: 40%;'>" + ar[i][0] + "</td>";
            output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][1] == 1 ? 'checked' : '') + " /></td>";
            output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][2] == 1 ? 'checked' : '') + " /></td>";
            output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][3] == 1 ? 'checked' : '') + " /></td>";
            output += "<td style='width: 30%;'><input type='text' value='" + ar[i][4] + "'/><input type='hidden' value='" + ar[i][5] + "' /></td>";
            output += "</tr>"
        }
        $('#projGrid').html(output);
    }

I am passing the information from vb.net using an `ArrayList.

Here is my html,

<div class="modalPopup" id="projPopup" style="width: 40%;">
                <table style="width:100%;">
                    <tr>
                        <td colspan="2">
                            <table id="projGrid" runat="server" style="width: 100%;border: 1px solid black; font-size: 16;">
                            </table>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="projOk" runat="server" Text="Update" /></td>
                        <td>
                        <asp:Button ID="projCncl" runat="server" Text="Cancel" />
                        </td>
                    </tr>
                </table>
            </div>

and here is my vb.net.

For Each row As HtmlTableRow In projGrid.Rows
            'Dim chkBond As HtmlInputCheckBox = row.Cells(1).Controls(0)
            Dim str As String
            str = row.Cells(0).InnerText
        Next

I have a web API 2 project and I have entity framework code first models which has some foreign keys to identity version 2 users table that is bound to webapi 2 project. since I have another provider project I have a reference to provider in my service (web api 2) project and since provider needs a reference to models putting models in service project cause circular reference. long story short I need to be able to move the code first models to a new project called Models to be used in both project. The problem is that no matter how hard I tried I couldn't move the IdentityUser Model to a separate project since it needs reference to Microsoft.AspNet.Identity.EntityFramework

below is an example of one of the models I use and ApplicationUser derives from IdentityUser

public class Application
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string Owner { get; set; }
    public string Company { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string PaymentInfo { get; set; }
    public DateTime CreateDate { get; set; }
    public DateTime ExpireDate { get; set; }

    public virtual ApplicationUser User { get; set; }
    public virtual ICollection<Billing> Billings { get; set; }
}

I'm using PHP Codeigniter atm. I've read a couple posts that stresses the "Fat Model and Thin Controller" and that the model is supposed to handle all the business logic, have the methods that deal directly with database and controllers deal directly with user input. Following these rules, it seems necessary to pass the $_POST array data indirectly to model through controller. But sometimes it's much more straight forward and almost necessary to deal with the user data directly in the controller

Also CI's form_validation class doesn't let you set custom error messages in the form_validation.php in the config file. To do that we need to write call_back methods. But if we gonna write call_back methods for each field, the controller is going to get 'fat' and also why would I use the form_validation class in the first place.

Another thing is that often at times I find the need to generate content according to the database and user input and etc. But doing so in the controller seems to go against the "separation of logic and presentation". For example, CI has a form and table helper, pagination, etc... These are all presentation stuff. And writing these in the controller will make controllers fat again. So I guess I should maybe write controller methods for view generation or should I write a model or library to deal with presentation?

I'd appreciate some good advice and hints on the general MVC approach. Thank you.

I am wondering what the best approach is to build a simple webpage like this mockflow layout. It's not that I am new to MVC itself. I just don't know the common way of building pages. See the following code how I would approach it. Note, I am only interested in the viewmodels and views.

ViewModels

public class FoodModel
{
    public CategoryModel CategoryModel { get; set; }
    [Display(Name="Pizzas")]
    public PizzaModel PizzaModel { get; set; }
    [Display(Name="Sandwiches")]
    public SandwichModel SandwichModel { get; set; }
    [Display(Name="Meats")]
    public MeatModel MeatModel { get; set; }
}

public class CategoryModel
{
    public int SelectedCategoryId {get; set; }
    public string RandomField { get; set; }
}

public class PizzaModel
{
    public IList<PizzaRow> PizzaRows {get; set; }
}

public class PizzaRow
{
    public string Name { get; set; }
    public string Ingredients { get; set; }
}

public class SandwichModel
{
    public IList<SandwichRow> SandwichRows {get; set; }
}

public class SandwichRow
{
    public string Name { get; set; }
    public string Ingredients { get; set; }
    public decimal Price { get; set; }
}

public class MeatModel
{
    public IList<MeatRow> MeatRows {get; set; }
}

public class MeatRow
{
    public string Name { get; set; }
    public string Animal { get; set; }
    public int Weight { get; set; }
}

Index-view and EditorTemplates for each Model and its Rows.

<!-- ~Views/Food/Index.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model FoodModel

    @Html.EditorFor(x => x.CategoryModel) @*For generating the top bar*@
    <div>@Html.LabelFor(x => PizzaModel)</div>@*For grid name 'Pizzas'*@
    @Html.EditorFor(x => x.PizzaModel)
    <div>@Html.LabelFor(x => SandwichModel)</div>@*For grid name 'Sandwiches'*@
    @Html.EditorFor(x => x.SandwichModel)
    <div>@Html.LabelFor(x => MeatModel)</div>@*For grid name 'Meats'*@
    @Html.EditorFor(x => x.MeatModel)

<!-- ~Views/Food/EditorTemplates/CategoryModel.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model CategoryModel

    @Html.DropDownListFor(x => x.SelectedCategoryId, ViewBag.Categories)
    @Html.DisplayFor(x => x.RandomField)

<!-- ~Views/Food/EditorTemplates/PizzaModel.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model PizzaModel

    <table>
        <thead>
            <tr>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Name)</th>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Ingredients)</th>
            </tr>
        </thead>
        Html.EditorFor(x => x.PizzaRows);
    </table>

<!-- ~Views/Food/EditorTemplates/SandwichModel.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model SandwichModel

    <table>
        <thead>
            <tr>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Name)</th>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Ingredients)</th>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Price)</th>
            </tr>
        </thead>
        Html.EditorFor(x => x.SandwichRows);
    </table>


<!-- ~Views/Food/EditorTemplates/MeatModel.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model MeatModel

    <table>
        <thead>
            <tr>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Name)</th>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Animal)</th>
                <th>@Html.LabelFor(x => x.PizzaRows.FirstOrDefault().Weight)</th>
            </tr>
        </thead>
    Html.EditorFor(x => x.MeatRows);
    </table>


<!-- ~Views/Food/EditorTemplates/PizzaRow.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model PizzaRow

    <tr>
        <td>@Html.DisplayFor(x => x.Name)</td>
        <td>@Html.DisplayFor(x => x.Ingredients)</td>
    </tr>

<!-- ~Views/Food/EditorTemplates/SandwichRow.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model SandwichRow

    <tr>
        <td>@Html.DisplayFor(x => x.Name)</td>
        <td>@Html.DisplayFor(x => x.Ingredients)</td>
        <td>@Html.DisplayFor(x => x.Price)</td>
    </tr>

<!-- ~Views/Food/EditorTemplates/MeatRow.cshtml -just the nessecary razor-code. don't mind the layout-->
@Model MeatRow

    <tr>
        <td>@Html.DisplayFor(x => x.Name)</td>
        <td>@Html.DisplayFor(x => x.Animal)</td>
        <td>@Html.DisplayFor(x => x.Weight)</td>
    </tr>

Would this be a decent approach or am I a fool for using those EditorFor's instead of Partials. Or maybe there is other advice and tips. Thanks for your time and advice.

I'm trying to display some charts on my mvc app but I'm having some errors. I'm developing in localhost. I have one cshtml file named ReportChart

@{
var myChart = new Chart(width: 600, height: 400)
    .AddTitle("Chart Title")
    .AddSeries(
        name: "Employee",
        xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" },
        yValues: new[] { "2", "6", "4", "5", "3" })
    .Write();

}

and another file that use that chart:

<body>
<h1>Chart Example</h1>
<p>The following chart is generated by the <em>ReportChart.cshtml</em> file:</p>
<p><img src="ReportChart.cshtml" alt="Cricketers" /> </p>

The only problem is that the webpage doesn't display any image :/

My Html link is well formatted . It resides inside my form ( post method ) . Although the link opens up in a separate window, it doesn't work inside the form. Is there any thing that hurts my link from opening ?

 <a href="file:///C:\uploads\test.doc">View Attachment</a>

Help appreciated...!

Additional Info

The target controller has a parameter of type FormCollection

I have an update panel inside of bootstrap modal which is not posting back, i tried adding triggers to the update panel but it still won't postback. i searched for solutions but i couldn't find any any suggestions ?

    <div class="modal ecash-transfer fade" aria-hidden="true" role="dialog" aria-labelledby="backLabel">

        <div class="modal-dialog">
            <div class="modal-content">

                <div class="modal-header">
                    <button aria-hidden="true" data-dismiss="modal" class="close" type="button">
                        x
                    </button>

                    <h4 class="modal-title" id="backLabel">E-Cash Transfer</h4>
                </div>

                <asp:UpdatePanel runat="server" ID="update_pnl_ecash_transfer" ClientIDMode="Static">
                    <ContentTemplate>

                        <asp:Panel class="errorHandler alert alert-danger " runat="server" Visible="false" ID="pnl_money_transfer_error">
                            <i class="fa fa-remove-sign"></i>
                            <asp:Literal runat="server" Text="You have some form errors. Please check below."
                                ID="lbl_money_transfer_errors" />
                        </asp:Panel>

                        <div class="modal-body">

                            <div class="form-group">

                                <label for="txt_ecash_amount" class="control-label">
                                    Amount
                                </label>

                                <div>
                                    <asp:TextBox runat="server" ID="txt_ecash_amount" ClientIDMode="Static" CssClass="form-control"
                                        data-required="required" onblur="isAllNumbers(this)" />
                                </div>

                            </div>

                            <div class="form-group">

                                <label for="txt_cash_pin" class="control-label">
                                    Pin
                                </label>

                                <div>
                                    <asp:TextBox runat="server" ID="txt_ecash_pin" ClientIDMode="Static" CssClass="form-control"
                                        data-required="required" onblur="pinLimit(this)" TextMode="Password" />
                                </div>

                            </div>

                        </div>

                        <div class="modal-footer">

                            <button data-dismiss="modal" class="btn btn-default" type="button">
                                Cancel
                            </button>

                            <asp:UpdateProgress runat="server" ID="pnl_progress" AssociatedUpdatePanelID="update_pnl_ecash_transfer">
                                <ProgressTemplate>

                                    <img src="assets/images/loading.gif" />

                                </ProgressTemplate>
                            </asp:UpdateProgress>

                            <asp:Button runat="server" ID="btn_ecash_transfer" ClientIDMode="Static"
                                CssClass="btn btn-primary" Text="Transfer" OnClick="btn_ecash_transfer_Click" />

                            <asp:Button runat="server" ID="btn_test" Text="test" OnClick="btn_test_Click" />

                        </div>

                    </ContentTemplate>
                </asp:UpdatePanel>

            </div>
        </div>

    </div>

I'm looking for advice before I start (newbie). I have a page displaying current capacitor data (in formview) based upon a dropdown list containing the capacitor part number. Likewise I have a separate page displaying archive data (in formview) for the same parts, again based upon a dropdown list containing the part number.

I would like to set this up to give the user the capability to go from the current data page to the archive page (for the same part) and return back to the original page. An added quirk is that the archive table may contain several listings for the part and all must be able to be viewed (Rev. A, Rev. B, etc). I have the individual pages set up any they work quite well as they currently stand.

What is the best way to accomplish this? Does anyone have any examples I could follow? The language of choice is VB.

I have a page that displays a GridView containing an ImageButton TemplateField. My goal is to display an AJAX modal popup when one of those buttons are clicked, along with displaying the row where the button is pressed. The problem is that when I click on a button, it does not show the modal popup. I tried to use this tutorial and read several articles on this site about this issue but to no avail. How to properly fire the button event and show the popup?

Here is the snippet for the gridview:

   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            Width="505px" DataSourceID="SqlDataSource1">
            <Columns>

                <asp:BoundField DataField="ItemDesc" 
                    SortExpression="ItemDesc" ItemStyle-Width="100px" ItemStyle-Height="100px">
    <ItemStyle Height="100px" Width="100px"></ItemStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Price" SortExpression="Price" 
                    ItemStyle-Width="100px" ItemStyle-Height="100px">

    <ItemStyle Height="100px" Width="100px"></ItemStyle>
                </asp:BoundField>

              <asp:TemplateField>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Image ID="Image1" runat="server" Height="200px" 
                        ImageUrl='<%# Eval("ImagePath") %>' Width="200px" />
                </ItemTemplate>
            </asp:TemplateField>

                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton1" runat="server" CommandName="atc"         ImageUrl="~/App_Themes/img/shop/addtocart.png" 
                            Text="Add to Cart" CommandArgument="<%# ((GridViewRow)     Container).RowIndex %>"/>
                    </ItemTemplate>
                    <ControlStyle Height="30px" Width="105px" />
                    <ItemStyle Width="105px" />
                </asp:TemplateField>

            </Columns>
        </asp:GridView>
...
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="HiddenField1" PopupControlID="Panel1" BackgroundCssClass="modalBg" CancelControlID="btnClose">
</asp:ModalPopupExtender>
<asp:HiddenField ID="HiddenField1" runat="server" />

And here's my code for the event:

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("atc"))
        {
            ModalPopupExtender1.Show();

            //// Retrieve the row index stored in the 
            //// CommandArgument property.
            int index = Convert.ToInt32(e.CommandArgument);

            //// Retrieve the row that contains the button 
            //// from the Rows collection.
            GridViewRow row = GridView1.Rows[index];
            lblItemName.Text = row.Cells[0].Text;
            lblPrice.Text = row.Cells[1].Text;

            Response.Write("<script>alert('" + row.Cells[0].Text + "\n" + row.Cells[1].Text +     "');</script>");

            //// Add code here to add the item to the shopping cart.
        }

    }

I am trying to follow this tutorial.

When using the feature to automatically generate UpdateMethod, my auto-generated method has no parameter. It is just Update(). The tutorial shows "studentsGrid_UpdateItem(int id)" Having the same issue with DeleteMethod. The name of auto-generated method can't be more generic. Without an id, what am I supposed to do?

So I am basically dead in the water and can't proceed. Googling isn't turning up anything.

EDIT: This may be my problem. The tutorial has a Models folder, and classes within it. It has validation attributes like this.

[Required, StringLength(40), Display(Name="Last Name")]
public string LastName { get; set; }

That is nice and all, but my classes are EF classes in a different class library compiled into a DLL (and I am not supposed manually edit them anyway). Could this be an issue for the problem I am having above?

One of the three attributes (Display) is strictly a UI issue which does not belong to the DLL. So where should the validation attribute go? The structure (Models folder, etc) won't work for me with a separate class library.

Here is my gridview code for displaying a pivot table from main data source

<%@ Page Language="C#" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

protected void btnSend_Click(object sender, EventArgs e)
{

    Response.Redirect("Elect_CrewAccid.aspx?strdt=" + txtstrdt.Text + "&enddt=" + txtenddt.Text + "&reportedto=" + txtrepdt.Text);

} 

 </script>
 <script runat="server">
protected void Page_Load(object sender, EventArgs e)
{

    if (!IsPostBack)
    {

        lblstrdt.Text = Request.QueryString["strdt"];
        lblenddt.Text = Request.QueryString["enddt"];
        lblreprtd.Text = Request.QueryString["reportedto"];
        if (Request.QueryString["reportedto"] == "") lblreportedto.Text = "Railway & Railway Board";
        if (Request.QueryString["reportedto"] == "RLY") lblreportedto.Text = "Railway";
        if (Request.QueryString["reportedto"] == "RLBD") lblreportedto.Text = "Railway Board";

    }

}
 </script>
 <script runat="server">

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        switch ((e.Row.FindControl("Label2") as Label).Text)
        {
            case "SPAD":
                e.Row.BackColor = System.Drawing.Color.Pink;
                break;

        }
    }
}

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
    .style2
    {
        font-size: small;
        font-family: Arial, Helvetica, sans-serif;
    }
    .style3
    {
        font-family: Arial, Helvetica, sans-serif;
        font-weight: bold;
    }
    .style4
    {
        font-family: Tahoma;
    }
    .style6
    {
        font-weight: bold;
    }
    .style7
    {
        font-family: Tahoma;
        font-weight: bold;
    }
    .style8
    {
        font-size: small;
        text-align: center;
        font-family: Tahoma;
    }
    .style9
    {
        font-family: Tahoma;
        font-size: small;
        font-weight: bold;
    }
    .style10
    {
        font-family: Tahoma;
        font-size: small;
    }
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center; font-weight: 700; font-family: 'Comic Sans MS'; color: #0000CC">
    Accident (including SPAD incidences) attributed to Loco Pilots under Administrative
    Control of Electrical</div>
<table align="left" style="font-family: Tahoma; font-size: small">
    <tr>
        <td style="font-family: Arial, Helvetica, sans-serif">
            <b>From Date:</b><asp:TextBox ID="txtstrdt" runat="server" Contenteditable="false" /><span
                class="style2">
                <asp:RequiredFieldValidator ID="DateRequiredFieldValidator" ControlToValidate="txtstrdt"
                    ErrorMessage="Name" Text="Can not be left blank" runat="server" Display="Dynamic"
                    ForeColor="Red" Font-Names="Tahoma" Font-Size="Small" />
                <ajax:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtstrdt"
                    Format="dd-MMM-yy">
                </ajax:CalendarExtender>
            </span>
        </td>
        <td style="margin-left: 80px">
            <span class="style3">Up to Date:</span><asp:TextBox ID="txtenddt" runat="server"
                Contenteditable="false" /><span class="style2">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtenddt"
                        ErrorMessage="Name" Text="Can not be left blank" runat="server" Display="Dynamic"
                        ForeColor="Red" Font-Names="Tahoma" Font-Size="Small" /></span>
        </td>
        <ajax:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtenddt"
            Format="dd-MMM-yy">
        </ajax:CalendarExtender>
        <td>
            <asp:Button ID="btnSend" Text="Submit" runat="server" onclick="btnSend_Click"/>
        </td>
    </tr>
</table>
<asp:RadioButtonList ID="txtrepdt" runat="server" Style="font-family: Tahoma; font-size: small">
    <asp:ListItem Text="Reoprted To Rly & Board" Value="" Selected="true"></asp:ListItem>
    <asp:ListItem Text="Reported to Rly" Value="RLY"></asp:ListItem>
    <asp:ListItem Text="Reported to Rly Board" Value="RLBD"></asp:ListItem>
</asp:RadioButtonList>
<div>
    <table align="center">
        <tr>
            <td class="style9" align="center">
                <span class="style10"><strong>Cases From Date: </strong></span><span class="style6">
                    <asp:Label ID="lblstrdt" runat="server" Style="color: #CC0000" CssClass="style10" /></span>
            </td>
            <td class="style11" align="center">
                <span class="style10"><strong>&nbsp;to: </strong></span>
                <asp:Label ID="lblenddt" runat="server" Style="color: #CC0000" CssClass="style9" />
            </td>
            <td class="style9" align="center">
                &nbsp;
            </td>
            <td class="style9" align="center">
                &nbsp;
            </td>
            <td class="style7" align="center">
                <span class="style10"><strong>Reprorted to: </strong></span>
                <asp:Label ID="lblreportedto" runat="server" Style="color: #CC0000;" CssClass="style9" />
            </td>
            <td class="style10" align="center">
                <strong>Category</strong>
            </td>
            <td class="style7" align="center">
                <span class="style4"></span>
                <asp:Label ID="lblreprtd" runat="server" Visible="false" Style="color: #CC0000;"
                    CssClass="style9" />
            </td>
        </tr>
    </table>
</div>
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajax:ToolkitScriptManager>
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
    CellPadding="4" DataSourceID="SqlDataSource1" ShowFooter="True" ShowHeaderWhenEmpty="True"
    EmptyDataText="Oops.... nothing to diplay! Select another dates." HorizontalAlign="Center"
    OnRowDataBound="GridView1_RowDataBound" BackColor="White" BorderColor="#CC9966"
    BorderStyle="Solid" BorderWidth="1px">
    <Columns>
        <asp:TemplateField HeaderText="Classification" SortExpression="Classification" HeaderStyle-VerticalAlign="Middle"
            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Middle"
            ItemStyle-Wrap="true">
            <EditItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Classification") %>'></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Classification") %>'></asp:Label>
            </ItemTemplate>
            <FooterTemplate>
                Total
            </FooterTemplate>
            <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
            <FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" Font-Bold="True" Font-Names="Tahoma" />
            <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Wrap="True"></ItemStyle>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="CR" SortExpression="CR">
            <EditItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Eval("CR") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>

            <asp:HyperLink ID="LabeCR" runat="server" Text='<%# Eval("CR") %>' NavigateUrl='<%# String.Format("~/detailspage.aspx?Rly=CR&Classification={0}", Eval("Classification")) %>'></asp:HyperLink>

            </ItemTemplate>
            <FooterTemplate>
                <asp:GridView ID="GridViewCR" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center"
                    DataSourceID="SqlDataSourceCR" ShowHeader="False" RowStyle-VerticalAlign="Middle"
                    RowStyle-HorizontalAlign="Center" GridLines="None" SelectedRowStyle-VerticalAlign="Middle"
                    SelectedRowStyle-HorizontalAlign="Center">
                    <Columns>
                        <asp:BoundField DataField="Total" HeaderText="Total" ReadOnly="True" SortExpression="Total"
                            ShowHeader="False" ItemStyle-Font-Bold="true" ItemStyle-Font-Names="Tahoma" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-VerticalAlign="Middle" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceCR" runat="server" CancelSelectOnNullParameter="false"
                    ConnectionString="<%$ ConnectionStrings:EsafetyConnectionString %>" SelectCommand="safety_summary_TTL"
                    SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="reportedto" QueryStringField="reportedto" Type="String" />
                        <asp:QueryStringParameter Name="strdt" QueryStringField="strdt" Type="DateTime" />
                        <asp:QueryStringParameter Name="enddt" QueryStringField="enddt" Type="DateTime" />
                        <asp:QueryStringParameter DefaultValue="CR" Name="Railway" QueryStringField="Railway"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </FooterTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="ER" SortExpression="ER">
            <EditItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Eval("ER") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:HyperLink ID="LabeCR" runat="server" Text='<%# Eval("ER") %>' NavigateUrl='<%# String.Format("~/detailspage.aspx?Rly=ER&Classification={0}", Eval("Classification")) %>'></asp:HyperLink>
            </ItemTemplate>
            <FooterTemplate>
                <asp:GridView ID="GridViewER" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center"
                    DataSourceID="SqlDataSourceER" ShowHeader="False" RowStyle-VerticalAlign="Middle"
                    RowStyle-HorizontalAlign="Center" GridLines="None" SelectedRowStyle-VerticalAlign="Middle"
                    SelectedRowStyle-HorizontalAlign="Center">
                    <Columns>
                        <asp:BoundField DataField="Total" HeaderText="Total" ReadOnly="True" SortExpression="Total"
                            ShowHeader="False" ItemStyle-Font-Bold="true" ItemStyle-Font-Names="Tahoma" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-VerticalAlign="Middle" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceER" runat="server" CancelSelectOnNullParameter="false"
                    ConnectionString="<%$ ConnectionStrings:EsafetyConnectionString %>" SelectCommand="safety_summary_TTL"
                    SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="reportedto" QueryStringField="reportedto" Type="String" />
                        <asp:QueryStringParameter Name="strdt" QueryStringField="strdt" Type="DateTime" />
                        <asp:QueryStringParameter Name="enddt" QueryStringField="enddt" Type="DateTime" />
                        <asp:QueryStringParameter DefaultValue="ER" Name="Railway" QueryStringField="Railway"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </FooterTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Total" SortExpression="Total">
            <EditItemTemplate>
                <asp:Label ID="LabelTotal" runat="server" Text='<%# Eval("Total") %>'></asp:Label>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="LabelTotal" runat="server" Text='<%# Bind("Total") %>'></asp:Label>
            </ItemTemplate>
            <FooterTemplate>
                <asp:GridView ID="GridViewTotal" runat="server" AutoGenerateColumns="False" HorizontalAlign="Center"
                    DataSourceID="SqlDataSourceTotal" ShowHeader="False" RowStyle-VerticalAlign="Middle"
                    RowStyle-HorizontalAlign="Center" GridLines="None" SelectedRowStyle-VerticalAlign="Middle"
                    SelectedRowStyle-HorizontalAlign="Center">
                    <Columns>
                        <asp:BoundField DataField="Total" HeaderText="Total" ReadOnly="True" SortExpression="Total"
                            ShowHeader="False" ItemStyle-Font-Bold="true" ItemStyle-Font-Names="Tahoma" ItemStyle-HorizontalAlign="Center"
                            ItemStyle-VerticalAlign="Middle" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSourceTotal" runat="server" CancelSelectOnNullParameter="false"
                    ConnectionString="<%$ ConnectionStrings:EsafetyConnectionString %>" SelectCommand="safety_summary_TTL"
                    SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="reportedto" QueryStringField="reportedto" Type="String" />
                        <asp:QueryStringParameter Name="strdt" QueryStringField="strdt" Type="DateTime" />
                        <asp:QueryStringParameter Name="enddt" QueryStringField="enddt" Type="DateTime" />
                        <asp:QueryStringParameter  Name="Railway" QueryStringField="Railway"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </FooterTemplate>
        </asp:TemplateField>
    </Columns>
    <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
    <HeaderStyle BackColor="#FFFFCC" Font-Bold="True" ForeColor="Black" HorizontalAlign="Center"
        VerticalAlign="Middle" Font-Names="Tahoma" />
    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
    <RowStyle Font-Names="Tahoma" ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle"
        BackColor="White" />
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
    <SortedAscendingCellStyle BackColor="#FEFCEB" />
    <SortedAscendingHeaderStyle BackColor="#AF0101" />
    <SortedDescendingCellStyle BackColor="#F6F0C0" />
    <SortedDescendingHeaderStyle BackColor="#7E0000" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" CancelSelectOnNullParameter="false"
    ConnectionString="<%$ ConnectionStrings:EsafetyConnectionString %>" SelectCommand="safety_summary"
    SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:QueryStringParameter Name="reportedto" QueryStringField="reportedto" Type="String" />
        <asp:QueryStringParameter Name="strdt" QueryStringField="strdt" Type="DateTime" />
        <asp:QueryStringParameter Name="enddt" QueryStringField="enddt" Type="DateTime" />
    </SelectParameters>
</asp:SqlDataSource>
</form>
<p class="style8">
    <strong><a href="../../elocosmainpage.htm">Home</a></strong></p>
</body>
</html>

Now the difficulty is that how to add values of 'lblstrdt', 'lblenddt' & 'lblreprtd' to following hyperlink

 <asp:HyperLink ID="LabeCR" runat="server" Text='<%# Eval("CR") %>' NavigateUrl='<%# String.Format("~/detailspage.aspx?Rly=CR&Classification={0}", Eval("Classification")) %>'></asp:HyperLink>

so that I can get the following query string to display corresponding record(s) on details page

 "~/detailspage.aspx?Rly=CR&Classification=xxxx&strdt=xx/xx/xx&enddt=xx/xx/xx&reprtd=xxxxx"

Or kindly suggested another method / code to obtain the desired results. I am unable to find out solution even doing lot of googling. Link to my webpage where this hyperlink is required to be implemented is - http://elocos.railnet.gov.in/ElectSafety/Elect_CrewAccid.aspx. Please help.

I'm using MV5 with VisualStudio 2013.

I've created a folder called App_GlobalResources and added 3 files:

  • LocalizedText.resx
  • LocalizedText.fr.resx
  • LocalizedText.sv.resx

And in each file I added the name Login with the value corresponding to each language. My Login page looks like this:

@model IdentitySample.Models.LoginViewModel
@{
ViewBag.Title = Resources.LocalizedText.Login;
}
<h2>@ViewBag.Title</h2>
....

Whenever I change the priority language of my browser I only get the English Title version. What am I doing wrong????

I want to output 2 specific pieces of information on the navigation and menu that will be shown on all pages through the _Layout.cshtml page. These things are: - First and Last Name of the logged in user - A dynamic menu that retrieves menu items from the logged in user

I want the First Name, Last Name and Menu to be cached (and perhaps updated on every login or after a certain period of time) as I don't want a hit to the database with every page load...however I really have no idea how to go about this.

I know how to create the models, persist the data and generate the menu itself, however I do not know how I go about caching this data, and displaying it through _Layout.cshtml, as this file doesn't appear to be tied to a Controller.

Any advice or best practice how to: - Cache data at logon - Show this through the _Layout.cstml

I'm pretty new in angularJs and i love it . i made a simple app with angularJs and i want to connect it to database .

This is the link that i made : http://angular.webpen.ir/Add/

how can i achive this ? for example after adding new user , it will save to DB (mysql) .

simply i want to track this app .

Thx a million

I'm new to ASP.NET MVC 5 Razor and I need some help how can I upload rows in my database.

I also use EF6 existing database for my model.

This is what I'm trying to do:

@if (Request.QueryString["GetUser"] != null && Request.QueryString["Update"] == "Open")
                            {
                                ViewBag.Notification = "Do you want to sync " + @Request.QueryString["GetUser"].ToString() + " to ActiveDirectory2?";
                            }
                            @if (Request.QueryString["GetUser"] != null && Request.QueryString["Update"] == "Update")
                            {
                                using(GWActiveDirectory.Models.GW_UTAEntities db = new GWActiveDirectory.Models.GW_UTAEntities())
                                {
                                    var query = "UPDATE ActiveDirectory2"
                                              + " SET SamAccountName = '" + DataStorage.Rows[0][0].ToString() 
                                              + "', EmployeeNumber = '" + DataStorage.Rows[0][9].ToString()
                                              + "', GivenName = '" + DataStorage.Rows[0][4].ToString() 
                                              + "', Surname = '" + DataStorage.Rows[0][1].ToString() 
                                              + "', EmailAddress = '" + DataStorage.Rows[0][5].ToString() 
                                              + "', Enable = '" + DataStorage.Rows[0][3].ToString() 
                                              + "', Guid = '" + DataStorage.Rows[0][2].ToString()
                                              + "', SID = '" + DataStorage.Rows[0][6].ToString() 
                                              + "', DateCreated = '" + DataStorage.Rows[0][7].ToString() 
                                              + "', DateModified = '" + DataStorage.Rows[0][8] + "'"
                                              + " WHERE SamAccountName = @SamAccountName";
                                    db.ActiveDirectory2.SqlQuery(query,Request.QueryString["GetUser"])
                                    db.SaveChangesAsync();
                                    Response.Redirect("?SearchString=" + ViewBag.searchString + "&GetUser=" + Request.QueryString["GetUser"]);
                                }  

                            }

But the problem is when I try to run my program the table ActiveDirectory2 didn't update.

I have created 3 list e.g. Country, State, Cities. I have populated them successfully & have sent selected value to the database table.

But during update operation as I have fetched the values of respective columns/fields, system is unable to find the selected values except the 'Country' drop down list. As it has been populating at page_load and rest of two are blank because no change has made to it. And I am trying to Select the value/item selected previously (during save/insert operation).

I am confused how could I bind the state and cities list on the value of Country available in the dataset.

Please suggest some ways.

Thanks you!

I have a CakePHP 2.4 project I am working on trying to fix, and I can;t seem to get the theme to properly display. There is one theme built out, just not showing. When I log the name of the theme to test it, the correct theme name is set, in the controller action, and also during beforeFilter and afterFilter execution.

So it appears as though it is loading the correct theme, however the default theme also shows. What should I test next to try and fix this?

I am building a basic PHP MVC framework that I can duplicate, use, and expand upon for my future projects. My folder layout is as follows:

MVC controllers {controllers here} libs Application.php Controller.php View.php models views error index.php index index.php _templates _header _footer .htaccess index.php

I have no problem with this framework as of now for a basic starting point (note that there are no real pages and content added to this framework at this point). My question deals with folder layout as well as Controller.php class logic. I have seen several basic platforms that seem to do it good have the Controller class looking like this:

<?php
    class Controller{
        public function model($model){
            require_once('../app/models/' . $model .'.php');
            return new $model;
        }

        public function view($view, $data= []){
            require_once('../app/views/' . $view . '.php');
        }
    }
?>

In a setup like this, frameworks do not have a View.php class because all of the UI logic that would normally be contained in the View.php class file is just handled in the View method of the Controller.php parent class, with some data passed in. The View method of the Controller.php class does what the View.php class would normally do, and just requires in certain files and renders out the view based off whatever data is in the data array $data [].

While this doesn't seem necessarily bad, it implies that the View.php class is simple enough to just include in the Controller.php class. My question is this, is the View class really that simple that it can just be merged into the Controller.php class? Or should there be more to the View class so that it deserves its own library class? I know there is a lot of debate around the exact purpose of the concept of a view, but I am just wondering if including a view method in the Controller.php class is a bad idea because that tells you you are not using the concept of a View correctly. Both setups seem to work I just see when I have a View.php class it seems I don't have enough to it to justify it having its own class, when it could be simply applied to the Controller.php class.

I would like some basic tips on implemenging a view properly and basically some opinions as to whether it should be merged into a Controller class or not. Thanks!