I've got a piece of JavaScript on a webpage that allows a user to scan in serial numbers and then it should send those to a webmethod where a database records it and a txtfile gets made.

It doesn't matter what's in the webmethod, because the code never runs. (Even removing the entire method and just make it change a bool to true as an example returns the same error). Here is the Js:

function sendingReady() {

  saveSerialNumbers();

  var employeeNr = document.getElementById("userCode").textContent;
  var productNr = document.getElementById("productCode").textContent;
  var cnt = {
    employeeNumber: employeeNr,
    productNumber: productNr
  };
  $.ajax({
    type: "POST",
    url: "WebServices.asmx/sendingReady",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: JSON.stringify({
      'cnt': cnt
    }),
    success: function() {
      console.log("Success sendingReady")
    },
    error: function() {}
  });
  var succes = "succes";
  localStorage.setItem("SuccesVerzenden", succes);
}

function saveSerialNumbers() {

  var scannedserials = [];
  var errorchoises = [];

  var Table = document.getElementById("SerialListContainer");
  var rowLength = Table.rows.length;

  for (i = 0; i < rowLength; i++) {
    var row = Table.rows[i];

    var serialnumber = row.childNodes[0].textContent;
    scannedserials.push(serialnumber);

    var errorChoice = row.childNodes[1].childNodes[0].value;
    errorchoises.push(errorChoice);
  }

  var cnt = {
    serialNumber: scannedserials,
    sendingErrorcode: errorchoises,
    personalNumber: document.getElementById("userCode").textContent,
    productNumber: document.getElementById("productCode").textContent
  };
  $.ajax({
    type: "POST",
    url: "WebServices.asmx/createSendingCeetisFile",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: JSON.stringify({
      'cnt': cnt
    }),
    success: function() {
      console.log("Success saveSerialNumbers")
    },
    error: function() {}
  });

}

To top function works, I get the "success SendingReady" message in my log. But the bottom function, called by the top one, does not. I've tried everything from sending the data as 4 separate instances, to changing the options in the Ajax call, to changing the recipient webmethod. This is said webmethod:

[System.Web.Services.WebMethod]
public void createSendingCeetisFile(SendingErrors cnt)
{
//unimportant code that doesn't ever run anyway; 
}

with sendingErrors being:

public class SendingErrors
{
    public string[] serialNumber { get; set; }
    public string[] sendingErrorcode { get; set; }
    public string[] dollies { get; set; }
    public string personalNumber { get; set; }
    public string productNumber { get; set; }
}

Dollies isn't being used yet. I'm using IIS and I haven't found any way to debug the server-side; All the IIS logs show is a generic '500' with no further detail.

I'm really hoping I'm missing something obvious, but after trawling through these forums and other sites looking for an answer for slightly over a day I'm kind of losing hope.

I have this HTML code with a div whose contents I want to pass to the controller. The div basically contains some span items of the label-primary class (link). I want to be able to get the names of the labels in this div in the controller. My idea was, as soon as the submit button is clicked, get the list of items that are inside the label-container div and pass their names to the controller as the List<string> OwnerTerminals value. How do I do that?

HTML + JS code:

@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
    ...
    <div id="register-terminal-panel" class="panel panel-default" style="max-width: 450px;">
        <div class="panel-heading" style="color:#003F8B">
            Add terminals to client
        </div>
        <div class="panel-body">
            <div id="label-container"></div>
            <div class="input-group input-group pull-right">
                <span class="input-group-addon">
                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                </span>
                <input id="register-terminals-search" type="text" class="form-control" placeholder="Search terminals" aria-describedby="search-addon" onkeyup="searchTerminals()">
            </div>
        </div>
        <ul id="register-terminal-list-container" class="list-group">
            @foreach (Point p in terminals)
            {
                <li id="list-item-@p.Name"><a href="javascript:void(0)" class="list-group-item" onclick="createLabel('@p.Name')">@p.Name</a></li>
            }
        </ul>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" class="btn btn-default" value="Register" />
        </div>
    </div>
}

<script>
    function closeLabel(item) {
        item.parentElement.remove();
        var listItem = '\n<li id="list-item-' + item.parentElement.id + '"><a href="javascript:void(0)" class="list-group-item" onclick="createLabel(\'' +
            item.parentElement.id + '\')">' + item.parentElement.id + '</a>';
        $('#register-terminal-list-container').append(listItem);
        sortUnorderedList("register-terminal-list-container");
    };

    function createLabel(name) {
        var label =
            '<span id="' + name + '" class="label label-primary terminal-label"><span class="glyphicon glyphicon-remove" onclick="closeLabel(this)" id="terminal-label-close-btn"></span> ' + name + '</span>\n'
        $('#label-container').append(label);
        $('#list-item-' + name).remove();
    };
</script>

Model:

public class RegisterViewModel
{
    ...
    public List<string> OwnerTerminals { get; set; }
}

Whenever an url is getting parsed in text message I am sending to user through asp.net it shows 500 Internal Server error.

Dim myMobile As String = "9999999999"
Dim myMsg    As String = "Booking Details " & vbCrLf & " " & vbCrLf 
    & "OEL32017734." & vbCrLf & "30 Pcs. (Auto parts)" & vbCrLf & "Pune-Chennai" & vbCrLf 
    & "Air (Normal)" & vbCrLf & "22/03/2017" & vbCrLf 
    & "OEL Office Pune  To OEL Office Chennai " & vbCrLf 
    & "OEL Office Pune  (Payee)" & vbCrLf & " " & vbCrLf 
    & "Track your shipment at http://www.orionexpresslogistics.com/track-shipments?bookingID=OEL32017734" & vbCrLf 
    & "Thank you for Booking."

Dim client  As New WebClient()
Dim baseurl As String = ""
Dim Data    As Stream = client.OpenRead( "http://smshorizon.co.in/api/sendsms.php?user=username&apikey=myAPI&mobile=" & myMobile & "&message=" & myMsg & "&senderid=ORILOG&type=uni" )
Dim reader  As New StreamReader(Data)
Dim ResponseID As String = reader.ReadToEnd()
Data.Close()
reader.Close()
Response.Write("Sent")

Exception

System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.WebClient.OpenRead(Uri address) at System.Net.WebClient.OpenRead(String address) at myadmin_horizon.myadmin_horizon_Load(Object sender, EventArgs e) in E:\MY WEB\Orion\myadmin\horizon.aspx.vb:line 12

I have here a model enter image description here

The company perfectly displays the subsector but I want to include the sector depending on what subsector the company belongs. How do I do that?

getElementById is returning null but the list is populated. Any guesses of what is wrong?

HomePage.aspx and Map.js

var Center = { lat: 20.452425, lng: -68.545446 };

function initMap() {
    
   
    map = new google.maps.Map(document.getElementById('map'), {
        zoom: 3,
        center: Center
    });   
    populateMap()
    function populateMap()
    {
        var DiveSiteList2 = document.getElementById("DiveSiteList")
         for (var i = 0; i < DiveSiteList2.options.length; ++i)
        {...}
        

    }
    }
<div id="ListHolder">
  <asp:ListBox class="ListBox" ID="DiveSiteList" runat="server"></asp:ListBox>
</div>

HomePage.aspx.cs

    private DiveManager.DiveManager Manager;
    protected void Page_Load(object sender, EventArgs e)
    {
        Manager = new DiveManager.DiveManager();
        BindDiveList();
    }

    private void BindDiveList()
    {
       foreach (DiveSite DS in Manager.MasterDiveSiteList)
        {
            ListItem Item = new ListItem();
            Item.Text = DS.DiveSiteName;
            Item.Attributes.Add("Name", DS.DiveSiteName);
            Item.Attributes.Add("Latitude", DS.Latitude.ToString());
            Item.Attributes.Add("Longitude", DS.Longitude.ToString());
            Item.Attributes.Add("ID", DS.DiveSiteID.ToString());
            DiveSiteList.Items.Add(Item);
        }
    }

Page error : Uncaught TypeError: Cannot read property 'options' of null at populateMap (Map.js:19)

Is there any ability to use masterpages inside masterpages in ASP.NET MVC 5?

I have a site and main layout page in it. And i have adminka controller with many pages, on any page here i want to add additional menu on site inside firstmasterpage. I am looking an idias how to handle it not using copypaste code in stile of DRY pattern.

I am building a web application for a parser. The home page is a simple razor view with basic controls, that will allow the user to add the input, and later will show the results of the parse. One of the components of this main page is a ViewComponent that returns one of the two relevant partial views for the parser's functionality: a first view that allows the user to add the input, and a result view showing the output. The decision of showing one or the other view will depend on a bool variable, "parsed", that will register whether the user has added input and parsed or not. We'll call the main page "Home", the input view "Main" and the output view "Results". If the user adds input and clicks the "Parse" button, "parsed" will be true and the Results view will load.

I have configured the logic and routes for this behaviour, and I can test it without a problem if I manually type the routes, adding the optional parameter. So, for example, all of these work properly:

  • localhost:1111/ -> Shows Main.
  • localhost:1111/?parsed=false -> Shows Main.
  • localhost:1111/?parsed=true -> Shows Result.
  • localhost:1111/parser/?parsed=false -> Shows Main, so on and so forth.

What's the problem then? When I hit the "Parse" button, I can't make the system retrieve the expected url localhost:1111/?parsed=true, obtaining instead localhost:1111/?. From this tutorial (and many more I've read) I understand that I need to use asp-route-[parameter], and that it has to match the signature of the method that is being called in asp-action, but I can't make it work.

This is the button in question:

<div class="col-2">
    <form>
        <button class="button"
                asp-controller="Home" asp-action="Index"
                asp-route-parsed="true">
            Start Parsing
        </button>
    </form>
</div>

And this is the method it calls:

    [Route("parser/{parsed:bool?}")]
    [Route("/{parsed:bool?}")]
    [Route("")]
    public ViewResult Index(bool parsed = false) {
        ViewData["Title"] = "Home";

        if (parsed == true) {
            Helper.parsed = true;
        } else {
            Helper.parsed = false;
        }

        return View("Index", Helper);
    }

I'll really appreciate some orientation here, I've read several articles and the documentation, but can't see where the problem is. In anyone would like to take a look at the whole system, the code is available here. Thanks in advance.

So I am coding a one page step by step booking process.
I have coded it so that when a button is clicked the content will toggle down.

This seems to have interfered with my VB.NET IF Statement behind one of the button click events as now the IF statement does not work.
It should show a div if something is not selected.

Can someone guide me on what to do please?

HTML:

<section>

  <div class="ChooseDoctor">    
    <div class="col-md-50 col-sm-50" style="text-align:center;">
      <h2>Choose your doctor</h2>

      <div class="alert alert-warning" id="warninginfo" runat="server">
        <strong>Warning!</strong> You have not selected your chosen doctor!
      </div> 

      <br />

      <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" SelectCommand="SELECT [FirstName], [Surname], [DoctorNumber], [ContactNumber] FROM [DoctorDetails]">
      </asp:SqlDataSource>
      <div class="col-md-50 col-sm-50" style="text-align:center;">
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="2" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" DataKeyNames="DoctorNumber" Height="411px" Width="824px" ShowHeader="False" HorizontalAlign="Center">
          <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
          <Columns>
            <asp:BoundField DataField="DoctorNumber" HeaderText="DoctorNumber" InsertVisible="False" ReadOnly="True" SortExpression="DoctorNumber" />
            <asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="Forename" />
            <asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
            <asp:CommandField ButtonType="Image" ShowSelectButton="True" SelectImageUrl="~/Images/buttonforbooking.png" />
          </Columns>        
        </asp:GridView>

        <br /> 

        <asp:Button ID="btnNextDate" runat="server" Text="Next Step" OnClientClick="return false;" BackColor="#02bdd5" ForeColor="#ffffff" CssClass="btn btn-default btn-send" Height="55px" Width="211px" Align="Center"/>
        <br />
      </div>
    </div>
  </div>

Code-Behind File:

warninginfo.Visible = False

 btnNextDate_Click(sender As Object, e As EventArgs) Handles btnNextDate.Click
If GridView1.SelectedValue = Nothing Then
    warninginfo.Visible = True
End If

JS File:

$(document).ready(function()
{

    $("[id$=btnNextDate]").click(function () {
        $("[id$=ChooseDate]").slideToggle('slow');
    });

I have html string:

tracking number is <a href='http://test.com/test?test=1' style='text-decoration: none; color: #0654ba;'>92000000000000000</a>.

and I want to get href and value, so I wrote pattern:

        string trackingUrlPattern = @"tracking number is <a href='(.*?)'.*>(.*?)<\/a>";


            match = Regex.Match(body, trackingUrlPattern);
            if (match.Success)
            {
                orderUrl = match.Groups[0].Value;
                trackingNumber = match.Groups[1].Value;
            }

but it doesn't work, what I'm wrong with the pattern?

Thank you!

Why does my .xsd dataset shows column of 1 query but not other 2 queries ?

I have used 3 queries in my stored procedure and used in my dataset for RDLC report but it does show columns of 1st query only not others.

My SP:

create PROC  [dbo].[SelectContractorsBio]

    @GC_ID INT

AS
BEGIN    



                   Select c.Name, c.FatherName, c.Farm, cat.Name 'Cat', c.CNIC, c.EnlistmentNo, c.ContactNo,
                   CONVERT(date,c.RegistrationDate,106) as RegistrationDate, c.Email, pcat.Name 'PECCat', c.PECCategoryNo 'PECLicenseNo',
                   c.PECReceiptNo, c.ExpectedDate, c.CNWEnlistmentNo, c.NTN, cr.BankName, cr.BankCode, cr.BankDraftNo, 
                   cat.Fee, cat.Amount, c.Address, Case when c.HasTaxExempted = 1 then 'Yes' else 'No' end
                   from Contractors c
                   Inner Join Category cat
                   ON Cat.ID= c.ContractorType_ID
                   Inner Join ContractorRenewal cr
                   ON cr.Contractor_ID= c.ContractorID
                   Inner Join PecCategories pcat
                   ON pcat.ID= c.PECCategoryID


                   Select Documents.DocumentID, Documents.Name from DocumentContractor dc
                   Inner Join Documents
                   ON Documents.DocumentID= dc.Doc_ID
                   where dc.Contractor_ID= @GC_ID

                   Select sc.SpecializationID, sc.Name 'SpecializationName', sc.SpecializationCode, spc.Contractor_ID from SpecializationCodes sc
                   INNER JOIN SpecializationCodeContractor spc
                   ON sc.SpecializationID= spc.SP_ID


END

Dataset:

enter image description here

I've got an ASP.NET MVC5 Project with EF6.

After doing an update to all nuget package including Microsoft.SqlServer.Types (ver 14.0.314.76), all the query related to spartial type not working any more, and it telling me to include this line of code inside my Application_Start() method in Global.asax.cs

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

But it doesn't fix the problems

Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
Additional information: Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

Here is what I've tried so far

  • Reinstall nuget package
  • Set the .dll in SqlServerTypes Folder to copy alsway, delete bin and obj folder and rebuild

To test if it working, insert this simple code to your Index method in HomeController

DbGeometry test = DbGeometry.FromText("POINT(297937 574201)", 27700);

I am using the following references of jQuery but unable figure out what files are conflicting, I am trying to use jQuery plugins to implement an event calendar.

If someone can point out what I am doing wrong it would be a great help. Thanks in advance. :

<link href="css/cupertino/jquery-ui-1.7.3.custom.css" rel="stylesheet" 
  type="text/css" />
<link href="fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css" 
/>

<script src="jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

<script src="jquery/jquery-ui-1.7.3.custom.min.js" type="text/javascript">
</script>

<script src="jquery/jquery.qtip-1.0.0-rc3.min.js" type="text/javascript">
</script>

<script src="fullcalendar/fullcalendar.min.js" type="text/javascript">
</script>

<script src="scripts/calendarscript.js" type="text/javascript"></script>

<script src="jquery/jquery-ui-timepicker-addon-0.6.2.min.js" 
type="text/javascript"></script>

I get the following error :

Uncaught TypeError: $(...).autocomplete is not a function
    at HTMLDocument.<anonymous> (Default.aspx:469)
    at Function.<anonymous> (jquery-1.3.2.min.js:19)
    at Function.each (jquery-1.3.2.min.js:12)
    at Function.ready (jquery-1.3.2.min.js:19)
    at HTMLDocument.<anonymous> (jquery-1.3.2.min.js:19)

script part:

$(document).ready(function () {
            $("#<%= this.addCustomer.ClientID%>").autocomplete({
                source: function (request, response) {
                    var param = { keyword: $("#<%= this.addCustomer.ClientID%>").val() };
                    $.ajax({
                        url: "Default.aspx/getCustomersName",
                        data: JSON.stringify(param),
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        dataFilter: function (data) { return data; },
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.split(" ")[0],
                                    val: item.split(" ")[1]
                                }
                            }))
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            alert(textStatus);
                        }
                    });
                },
                select: function (event, ui) {
                    if (ui.item) {

                        $("#<%=this.addCustomer.ClientID%>").val(ui.item.label+ui.item.val)
                        $("#<%=this.hfCustomerId.ClientID%>").val(ui.item.val)

                    }
                },
                minLength: 2
            });

I am trying to run an application but it's default setting has been changed. There were a start up page for every module. How do I set a default and what will be the requirements ?

I need to retrieve all rows from GridView1 and export to excel using C#. This static method below is called by Ajax however it says the GridView1 is a non-static field so I could not proceed. Is it possible to change the GridView1 to static field? Thanks in advance

 [WebMethod]
     public static string ExportExcel()
     {
        GridView1.AllowPaging = false;
        GridView1.DataBind();
        return null;
     }

Hi I'm using a Java script for make right a required in input filed and removing it based on tab click but its not working fine I need a batter solution so I can able to use required filled based on tab selected

here is a HTML Code

                <div class=" tsf-step step-3 ">
                        <h2 class="mb-none"><strong>Payment</strong> Option</h2>
                        <hr />
                        <div class="row">
                            <div class="col-md-4">
                                <div class="tabs tabs-vertical tabs-left tabs-navigation">
                                    <ul class="nav nav-tabs col-sm-3">
                                        <li class="active" onclick="checkboxPaypal()">
                                            <a href="#tabsNavigation1" data-toggle="tab" aria-expanded="true"><i class="fa fa-paypal"></i>PayPal</a>
                                        </li>
                                        <li class="" onclick="checkboxPaypalCard()">
                                            <a href="#tabsNavigation2" data-toggle="tab" aria-expanded="false"><span class="fa-stack" aria-hidden="true" style="margin-top: -8%;"><i class="fa fa-cc-visa" style="position: absolute; margin-top: 50%; margin-left: 16%;"></i>
                                                <i class="fa fa-paypal" style="color: green"></i></span>Card to PayPal</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            <div class="col-md-8">
                                <div class="tab-pane tab-pane-navigation active" id="tabsNavigation1">
                                    <h4>Checkout with Paypal</h4>
                                    <p><strong>Term &amp; Condition</strong></p>
                                    <p style="width: auto; height: 127px; border: 1px solid #ccc; background: #f2f2f2; padding: 6px; overflow: auto;">Payment via PayPal.</p>
                                    <p>
                                        <input type="checkbox" name="checkbox" id="checkboxPaypal" value="Paypal" required/>
                                        <label for="checkboxPaypal">Agree with Term &amp; Condition</label>
                                    </p>
                                </div>
                                <div class="tab-pane tab-pane-navigation" id="tabsNavigation2">
                                    <h4>Checkout with Visa/Master/American Express to Paypal</h4>
                                    <div class="row">
                                        <div class="tsf-step-content">
                                            <div class="col-lg-12">
                                                <div class="form-group">
                                                    <label>Card holder name *</label>
                                                    @Html.TextBoxFor(model => model.HolderName, new { @name = "HolderName", type = "text", id = "HolderName", placeholder = "Card Holder Name", @class = "form-control", maxlength = "50" })
                                                </div>
                                                <div class="form-group">
                                                    <label>Carde number *</label>
                                                    @Html.TextBoxFor(model => model.CardNumber, new { @name = "Cardnumber", type = "text", id = "Cardnumber", placeholder = "Card Number", @class = "form-control", maxlength = "19", pattern="[0-9]*"})
                                                </div>
                                            </div>
                                            <div class="col-lg-6">
                                                <div class="form-group">
                                                    <label for="email">Expiry date *</label>
                                                    @Html.TextBoxFor(model => model.ExpiryDate, new { @name = "ExpiryDate", type = "ExpiryDate", id = "ExpiryDate", placeholder = "Expiry Date", @class = "form-control", data_plugin_masked_input = "data-plugin-masked-input", data_input_mask = "99 / 9999" })
                                                </div>
                                            </div>
                                            <div class="col-lg-6">
                                                <div class="form-group">
                                                    <label>CCV number *</label>
                                                    @Html.TextBoxFor(model => model.CCVNumber, new { @name = "CCVnumber", id = "CCVnumber", placeholder = "CCV Number", @class = "form-control", maxlength = "4" , pattern="[0-9]*"})
                                                </div>
                                            </div>
                                            <div class="col-lg-12">
                                                <div class="form-group">
                                                    <label>Card Type *</label>
                                                    @Html.DropDownListFor(model => model.CardType, new List<SelectListItem> {
                                                   new SelectListItem { Text = "Visa", Value = "Visa"},
                                                   new SelectListItem { Text = "Master Card", Value = "Master Card"},
                                                   new SelectListItem { Text = "American Express", Value = "American Express" }
                                               }, "-- Choose Card Type --", new { @id = "CardType", @class = "form-control populate", data_plugin_selectTwo = "data-plugin-selectTwo", style = "width: 100%;" })
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <p><strong>Term &amp; Condition</strong></p>
                                    <p style="width: auto; height: 127px; border: 1px solid #ccc; background: #f2f2f2; padding: 6px; overflow: auto;">Payment via Visa / Master Card or American express to PayPal.</p>
                                    <p>
                                        <input type="checkbox" name="checkbox" id="checkboxPaypalCard" value="PaypalCard" />
                                        <label for="checkboxPaypalCard">Agree with Term &amp; Condition</label>
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                }
                <div class="tsf-controls ">
                    <button type="button" data-type="prev" class="btn btn-left tsf-wizard-btn"><i class="fa fa-chevron-left"></i>PREV</button>
                    <button type="button" data-type="next" class="btn btn-right tsf-wizard-btn">NEXT <i class="fa fa-chevron-right"></i></button>
                    <button type="submit" data-type="finish" class="btn btn-right tsf-wizard-btn">FINISH</button>
                </div>
            </div>

Here is a script

function checkboxPaypal() {
    $('input').attr('required', false)
    $('select').attr('required', false)
    $("#checkboxPaypalCard").prop("reqired", false);
    $("#checkboxPaypal").prop("reqired", true);
}
function checkboxPaypalCard() {
    $("#checkboxPaypal").prop("reqired", false);
    $('input').attr('required', true)
    $('select').attr('required', true)
    $("#checkboxPaypalCard").prop("reqired", true);    
}

Please let me know how can I correct the JavaScript for use reqired based on selecting tab and remove as well as per selected Payment Option.

I have a viewmodel class containing two viewmodels

public class SalesByBrandParentVM
    {
        public IEnumerable<SPSalesbyBrandModel> SpSalesByBrandModel { get; set;}

        public ReportSalesbyBrandVM ReportSalesByBrandModel { get; set; }
    }

My view looks like this:

@model MyStoreReports.ViewModels.SalesByBrandParentVM

@{
    ViewBag.Title = "Sales by Brand Page";
}
@section Styles {
    <link href="@Url.Content("~/css/report.css")" rel="stylesheet" type="text/css" />
}


<div class="row" >
    <div class="col-lg-2">


        <form method="post">
            <h2>Sales by Brand</h2>

            <input asp-for="FromDate" class="form-control" type="date" />
            <div class="form-group">
                <label asp-for="FromDate">FromDate</label>
                <span asp-validation-for="FromDate" class="text-muted"></span>
            </div>

            <input asp-for="ToDate" class="form-control"type="date"/>
            <div class="form-group">
                <label asp-for="ToDate">ToDate</label>
                <span asp-validation-for="ToDate" class="text-muted"></span>
            </div>

            <div class="form-group">
                <a asp-controller="App" asp-action="Index" class="btn btn-default">Cancel</a>
                <input type="submit" value="Submit" class="btn btn-success" />
            </div>
        </form>
    </div>
</div>



    <div>
        <table>
            <tr>
                <th>ClientCode</th>
                <th>TrxAmount</th>
            </tr>
            @foreach (var item in Model.SpSalesByBrandModel)
            {
                <tr>
                    <td>@item.ClientCode</td>
                    <td>@item.TrxAmount</td>
                </tr>
            }
        </table>
    </div>

public class SPSalesbyBrandModel
    {
        [Key]
        public string ClientCode { get; set; }

        public double TrxAmount { get; set; }

    }

public class ReportSalesbyBrandVM
    { 
        [Required]
        public DateTime FromDate { get; set; }

        [Required]
        public DateTime ToDate { get; set; }

    }
[HttpPost]
        public IActionResult ReportSalesbyBrand(ReportSalesbyBrandVM viewmodel)
        {
            var fdate = viewmodel.FromDate;
            var edate = viewmodel.ToDate;
            var category = viewmodel.Category;
            return View(_totalSalesRepository.GetSalesbyBrand(fdate,edate,category));
        }

Inside the table, i'm able to point to SpSalesByBrandModel model class. Is there a way to point FromDate and ToDate controls to ReportSalesByBrandModel viewmodel

Thanks in advance!!!

I have written a piece of code in PHP which basically looks like this:

$order = array( 
'0' => array( 
'user_order_sn' => '123', 
'country' => 'some', 
'firstname' => '123', 
'lastname' => '123', 
'addressline1' => 'AFDAFAF', 
'addressline2' => '', 
'shipping_method' => '123', 
'tel' => '551245', 
'state' => '4444', 
'city' => '55r', 
'zip' => '1004451', 
'order_remark' => 'test', 
'order_platforms' => 3, 
'original_order_id' => '7126216', 
'original_account' => '51251251', 
'original_order_amount' => 2.57, 
'goods_info' => array( 0 => array( 'goods_sn' => '6544321', 'goods_number' => 4
)
),
),
);

So as you can see order variable is array of arrays which contains a variable goods_info which also array of array inside it.

I would like to replicate this in c#. I suspect I need to use jagged arrays here, but I'm not 100% sure how to do that. I created a class for starters which contain all the info above:

  public class CreateOrderDataRequest
    {
        public string user_order_sn { get; set; }
        public string country { get; set; }

        public string firstname { get; set; }
        public string lastname { get; set; }

        public string addressline1 { get; set; }

        public string addressline2 { get; set; }
        public string shipping_method { get; set; }
        public string tel { get; set; }
        public string state { get; set; }
        public string city { get; set; }
        public string zip { get; set; }

        public string order_remark { get; set; }
        public string order_platforms { get; set; }
        public string original_order_id { get; set; }

        public string original_account { get; set; }
        public string original_order_amount { get; set; }
    }

Can someone help me out to finish this ? :)

P.S. I haven't finished the goods_info part because I'm not sure how to do that ...

I use the login control, that locally works well and worked well also on my host after following many tutorials to change the db layout. The password recovery controls and user controlo works without any problems, and I see the entry in the db, but the login don't work and I get this message every time: Your login attempt was not successful. Please try again.

This is my web.config:

 <?xml version="1.0"?>


<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->


<configuration>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="localhost" port="25" />
      </smtp>
    </mailSettings>
  </system.net>
    <system.web>
<customErrors mode="Off"/>      
      <authentication mode="Forms" />
      <compilation debug="false" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
<membership defaultProvider="AspNetSqlMembershipProvider">
        <providers>
          <clear/>


          <!--Provider aruba-->
          <add name="AspNetSqlMembershipProvider" 
               type="Microsoft.Samples.SqlMembershipProvider, ProviderToolkitSampleProviders" 
               connectionStringName="conn" 
               minRequiredPasswordLength="5" 
               minRequiredNonalphanumericCharacters="0" 
               requiresQuestionAndAnswer="false"
               applicationName="TestAruba1"/>


        </providers>
</membership>


<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider">
        <providers>
          <clear/>


          <!--Provider aruba-->
          <add name="AspNetSqlRoleProvider"
               type="Microsoft.Samples.SqlRoleProvider, ProviderToolkitSampleProviders"
               connectionStringName="conn" applicationName="TestAruba1"></add>
        </providers>
</roleManager>
    </system.web>

  <connectionStrings>
<add name="conn" 
    connectionString ="server=xx.xx.xx.xx;uid=MSSql123456;pwd=xxxxxxxxxx;database=MSSql123456"
    providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="none"></add>
  </appSettings> 
</configuration>

The Login Page is very simple:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Login ID="Login1" runat="server">
        </asp:Login>
        
    
    </div>
    </form>
</body>
</html>

Once again needed help from you experts, Heres the design

SQL MemberID CHAR(8)

The memberID usually is "M1" "M2" and so on However when I add into SQL via ASP.NET The command would be something like

List memList = member.GetAllMem(); // Basically retrieve from SQL and store inside a list

AddMember("M" + Convert.ToString(memberList.count() +1);

The problem with above code is when I delete member value inside SQL the numbering of the member would have problem and can be duplicate when I insert new member (because I use the Count) How to fix this issue?

Thanks.

I am developing a website that called myWall. when user wants to create a new wall, the user id is required. So, how can I get user Id of logged in user. I tried many ways that posted here (in stack overflow)

This is my create wall action method

[HttpGet]
    public ActionResult CreateWall()
    {

        return View();
    }

    [HttpPost]
    public ActionResult CreateWall(Wall wall)
    {

        var userId = User.Identity.GetUserId();



            if (ModelState.IsValid)
            {

                db.Walls.Add(wall);

                db.SaveChanges();

                return RedirectToAction("Index");

            }

        return View(wall);
    }

and this is my create wall view, when I create a new wall, id doesn't give any error, but it doesn't hit save changes.

{ @Html.AntiForgeryToken()

<div class="form-horizontal">
    <h4>Wall</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.Name, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Name, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
        </div>
    </div>





    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
</div>

}

I have a custom IFileProvider for RazorViewEngineOptions in a ASP.NET Core project. Is it possible to get access to the request object in GetFileInfo in the IFileProvider?

public class DBViewProvider : IFileProvider
{
    public IFileInfo GetFileInfo(string subpath)
    {
        // access to Request here? 
    }
}

Startup.cs:

public void ConfigureServices(IServiceCollection services)
{

    services.Configure<RazorViewEngineOptions>(options =>
        {               
            options.FileProviders.Add(new DBViewProvider());    
        });
}

There's only 1 global instance of the DBViewProvider so I'm unable to inject IHttpContextAccessor for every request.