below method lstImprtlogisticare is the object having data above 100kb. If the object having below 100kb data it is working fine.If more than 100kb getting communication exception as

The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

an the code is

public int ImportLogistiCareData(List<Importlogisticare> lstImportlogisticare, int VendorId, TransportationVendorTypes vendorType)
                using (LINAServiceClient oLINAServiceClient = new LINAServiceClient())
                    Mapper.CreateMap<Importlogisticare, IMPORTLOGISTICARE>()
                        .ForMember(dest => dest.ID, opts => opts.MapFrom(src => src.ID))
                        .ForMember(dest => dest.REGION, opts => opts.MapFrom(src => src.Region))
                        .ForMember(dest => dest.TRIPID, opts => opts.MapFrom(src => src.Trip_Id))
                        .ForMember(dest => dest.JOBNO, opts => opts.MapFrom(src => src.Job_No))
                        .ForMember(dest => dest.DATEOFSERVICE, opts => opts.MapFrom(src => src.Dateof_Service))                      
                        .ForMember(dest => dest.DATEOF_BIRTH, opts => opts.MapFrom(src => src.Dateof_Birth))
                        .ForMember(dest => dest.AGE, opts => opts.MapFrom(src => src.Age))
                        .ForMember(dest => dest.HOME_PHONE, opts => opts.MapFrom(src => src.Home_Phone));
                    IMPORTLOGISTICARE[] oIMPORTLOGISTICARE = Mapper.Map<IMPORTLOGISTICARE[]>(lstImportlogisticare);

                    return oLINAServiceClient.ImportFile(null, oIMPORTLOGISTICARE, VendorId, Convert.ToInt32(lstImportlogisticare[0].LASTUPDATEDBY), vendorType);

            catch (System.ServiceModel.CommunicationException)
            catch (Exception)

Having read this question, I found the answers outdated/depreciated and hence am asking if anyone would have any 'updated' answers to:

Does JQuery have a function call like

$('#myNewDivId').on('create', function(){


for a single div, or multiple 'appends':

$('.myNewDivWithClass').on('create', function(){


for a dynamically created div?

  • I would rather not include plugins (esp. 'outdated' ones like .livequery() plugin)
  • 'DOMSubtreeModified' seems to be depreciated, and so would there be an alternative?
  • I would need this function to be compatible with (at least) IE 10 + 11.

What I'm looking to do is on create of this 'new element', is to have an ajax call back to my controller to 'replace' this div with a partial view? However, without a jquery method to use, it seems more difficult than expected

I am new to MVC. So far, I succeeded in binding data from database in a drop down list.

How can I get the selected value and pass it to the Controller to be saved in the database?

Here's what I have done so far:


@Html.DropDownList("State", null, new { @class = "dropdown-toggle col-md-9 form-control" })

CONTOLLER: (this is how bound the data in the dropdown list)

  IEnumerable<SelectListItem> states = db.RefState
            .Select(s => new SelectListItem
                Value = s.ID.ToString(),
                Text = s.Name

        ViewBag.AddressType = types;
        ViewBag.State = states;
        return View();

This is how I save it in the database:

    public ActionResult NewAddress(Address data)
            var addressData = new Address()
                ZipCode = data.ZipCode,
                StreetNo = data.StreetNo,
                StreetName = data.StreetName,
                Unit = data.Unit,
                Additional = data.Additional,
                Town = data.Town,
                City = data.City,
                StateID = ?,  
                Description = data.Description,
                VendorCode = data.VendorCode


            data = null;
            ViewBag.Message = "Address succesfully added";
            return RedirectToAction("DeliveryInformation", "DeliveryDetail");

        return View(data);

We are using a session to gather products in a basket. This is just a project, and we know this isn't scalable or at all smart, it's just for show. In any case, everytime we add a product from our page, it will be added to the basket on the side through a basket. In this, we have the name, price and quantity. It adds fine as it should, but when we add the same product again it just add it to the list, not increment upon the existing product.

Is there an "easy" way to add some functionality to the existing code to do this, or is it a lost cause?

This is our controller action for adding it:

        public ActionResult Index(Dish dish)
            Basket basket;
            if (Session["Basket"] == null)
                basket = new Basket();
                Session["Basket"] = new Basket();
                basket = (Basket)Session["Basket"];
            BasketItem basketItem = new BasketItem();
            basketItem.DishId = dish.DishId; 
            basketItem.Title = dish.Title;
            basketItem.Number = dish.Number;
            basketItem.Price = dish.Price;


            return RedirectToAction("Index", basket.Items);


This is for showing it in our partial view:

        public ActionResult BasketItemsList()

            Basket basket;

            if (Session["Basket"] == null)
                basket = new Basket();
                Session["Basket"] = new Basket();
                basket = (Basket)Session["Basket"];

            return PartialView("_Basket", basket.Items);

I m stucked here very much and it is going some serious.

I have a Gridview which I am using to show the data from the backend. What I did is For inserting the data, I have made a button on top of the Gridview to add the data in the gridview.

Like this:-

<asp:Button ID="btnAdd" runat="server" CssClass="btn btn-prm" Text="Add" Width="75" CausesValidation="true" ValidationGroup="AddNew" OnClick="btnAdd_Click" />

The same is been done for Edit part also.

I have added a checkbox to select the row for the gridview.See my gridview code for better understanding,

<asp:GridView ID="grdCSRPageData" runat="server" Width="100%" border="1" Style="border: 1px solid #E5E5E5;" CellPadding="3"
                AutoGenerateColumns="False" OnDataBound="grdCSRPageData_DataBound" AllowPaging="true" CssClass="hoverTable"
                OnPageIndexChanging="grdCSRPageData_PageIndexChanging" DataKeyNames="Id" OnRowDeleting="grdCSRPageData_RowDeleting" 
                PageSize="5" ShowFooter="true" OnRowEditing="grdCSRPageData_RowEditing" OnRowUpdating="grdCSRPageData_RowUpdating" 
                <AlternatingRowStyle CssClass="k-alt" BackColor="#f5f5f5"/>
                    <asp:TemplateField HeaderText="Action" HeaderStyle-Width="5%" HeaderStyle-CssClass="k-grid td" >
                            <asp:Checkbox ID="chkSelect" runat="server" AutoPostBack="false" />
                    <asp:BoundField DataField="page_title"  HeaderText="Page Title" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td"  />
                    <asp:BoundField DataField="page_description" HeaderText="Page Description" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td" />
                    <asp:BoundField DataField="meta_title" HeaderText="Meta Title" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td" />
                    <asp:BoundField DataField="meta_keywords" HeaderText="Meta Keywords" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td" />
                    <asp:BoundField DataField="meta_description" HeaderText="Meta Description" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td" />
                    <asp:BoundField DataField="Active" HeaderText="Active" ItemStyle-Width="30" HeaderStyle-CssClass="k-grid td" />
                    <asp:TemplateField HeaderText="Action" HeaderStyle-Width="15%" HeaderStyle-CssClass="k-grid td" >
                            <asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/delete.png" runat="server" Width="15" Height="15" CommandName="Delete" CommandArgument='<%# Eval("Id") %>' CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this record?')" />
                    <asp:CommandField ButtonType="Image" ItemStyle-Width="15" EditImageUrl="~/images/edit.png" ShowEditButton="True" ControlStyle-Width="15" ControlStyle-Height="15" CancelImageUrl="~/images/close.png" UpdateImageUrl="~/images/update.png">
                        <ControlStyle Height="20px" Width="20px"></ControlStyle>

Now what my requirement is. Whenever I check the checkbox for any row, and click on the Update button, the repsective Row should get open in a popup with the existing data as it is getting for adding the new Row. I tried but couldn't succeed. Please help me with this. Let me know if you need anything else.


I am stuck with a problem where I have multiple tables in an update panel. I bind the gridview items from code behind when I click an button. This causes a postback which triggers my javascript pageLoad functions.

Inside the pageLoad block I have following function which gets the length of the table and either displays a detailed view if the length is 2 (one row) or displays the table when the length is more than 2. This works well.

    $(function () {
        var len = $("#<%=gvClave.ClientID%> tr").length;
        if (len > 2) {
            document.getElementById('frameClaveTable').style.display = 'block';
                width: $('#frameClaveTable').width(),
                height: 200
            $('#sliderClaveTable').animate({ width: $('#frameClaveTable').width() + 50 });
        } else if (len == 2) {
            showClaveDetails($("#<%=gvClave.ClientID%> tr"));

I have a third table in the same update panel which I bind when I search for a value in the SQL database. During the postback when I bind the third table I would expect the other tables to be reset and disappear from view. However in the postback pageLoad event the old table is still found and displayed again. I can't get my head around how to prevent this. I have tried to force a postback prior to refreshing the tables. I have tried to put the tables in seperate update panels but to no avail.

Any ideas on this issues are welcome.


I have a .NET web application on a server (the "proxy server") that relays data from a desktop application (the "streamer") to a client (the "client").

All communication involved uses web calls - that is, the .NET components (the streamer talking to the proxy server) uses WebClients, and the client uses javascript xmlHttp GET requests to retrieve data from the proxy server. It is here wherein my question lies.

A very simple version of the javascript loop is as follows:

var interval = setInterval(function () { getnum(); }, 250);

function getnum() {
    var xmlHttp = null;
    xmlHttp = new XMLHttpRequest();"GET", "getImage.aspx?param=val", false);
    var str = xmlHttp.responseText;
    xmlHttp = null;

    // various processing

if it matters, the responseText is a base64-encoded string, plus some extra ASCII data to help with the processing.

The streamer application uploads data every 250ms as well. The size of the data being transferred does not exceed 120K per transfer.

The Problem: For the most part, this works. Every now and then, though the server suddenly stops responding to these GET requests. I get a network error, Failed to execute 'send' on 'XMLHttpRequest': Failed to load '' When this happens, not only does the javascript fail to connect to the server, but other web browsers on other computers can't access the website at all (the root However! Looking at IIS access logs, it appears that the streamer applicaion is still successfully pushing data towards the server. There is no cross site stuff going on, and 90% of the time, this works just fine. I can't figure out what is causing the error to occur. I can't trigger the failure. The only way I can observer it happening is to sit here and watch the javascript calls in the developer console of whatever web browser I'm using (the problem exists across all browsers).

What is happening? And, why would it only fail on occasion?

I'm writing an ASCX control that needs to reference both a JavaScript file and a CSS file.

Obviously, I only want the host page to reference these files once. So I'm using Page.ClientScript.RegisterClientScriptInclude() to reference the JavaScript file. The CSS file, however, is a bit more complicated.

I thought maybe I could do the following:

if (!Page.ClientScript.IsClientScriptIncludeRegistered(ScriptManagerJsKey))
    Page.ClientScript.RegisterClientScriptInclude(this.GetType(), ScriptManagerJsKey, ResolveClientUrl("~/javascript/PaymentSchedule.js"));

    HtmlLink cssLink = new HtmlLink();
    cssLink.Href = "~/css/PaymentSchedule.css";
    cssLink.Attributes["rel"] = "stylesheet";
    cssLink.Attributes["type"] = "text/css";

The idea here was to add an HtmlLink to reference the CSS file in the page header, but only once. Since I believe this code will only add the JavaScript reference once, I thought this would do the trick.

However, this actually adds the reference to the CSS file twice in the head section of the file.

Has anyone found a trick to referencing a CSS file only once from an ASCX control?

I am proficient in MVC 5 but web api 2 is new to me. I am trying to add a webapi controller to my MVC Project, But I can't access It's path. Iv'e added a web api controller in a new Folder called webapi, and the name of the controller is searchcontroller, Inside My MVC 5 Project. I can't access it's path, something that should be: /api/search/get. I think It might be with something with my App Start in Global Ajax :

Help Please! Here is the code in the app start :

protected void Application_Start()
        GlobalConfiguration.Configure(config =>

        name: "ApiById",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional },
        constraints: new { id = @"^[0-9]+$" }

                name: "ApiByName",
                routeTemplate: "api/{controller}/{action}/{name}",
                defaults: null,
                constraints: new { name = @"^[a-z]+$" }

                name: "ApiByAction",
                routeTemplate: "api/{controller}/{action}",
                defaults: new { action = "Get" }

The controller code :

 public class WebAPISearchReultsController : ApiController
    public IEnumerable<ICE.Logic.ArticleSearchResult> Get(string searchQuery)
        return SearchLogic.Instance.GetArticleSearchResults(searchQuery);

I have an Account controller with two Get methods, one that gets all accounts and takes no input, and another that takes an Id int and returns that specific account.

The project constraints are that we can't have id as an optional parameter on the default route, but instead need get-one-account and get-all-accounts to be accessed via different routes, and we can't use attribute routing. So our route configuration currently looks like this:

config.Routes.MapHttpRoute("AccountWithId", "api/account/{id}", new { action = "Get", id = RouteParameter.Optional }
                , new { httpMethod = new HttpMethodConstraint(HttpMethod.Get), id = @"\d+" });

config.Routes.MapHttpRoute("Default", "api/{controller}");

My two Get methods on the AccountController look like this:

public IHttpActionResult Get()
            IList<AccountDto> users = m_service.Get();

            return Ok(users);

        public IHttpActionResult Get(int accountId)
            AccountDto user = m_service.Get(accountId);

            return Ok(user);

But when I call Get with an id parameter in my test via my custom route and debug as below, it's still hitting the Get method that doesn't take an id parameter and returns all.

var url = "http://test/api/account/" + accountId;

var response = await m_server.HttpClient.GetAsync(url);

Any idea why?

If the end user scrolls down a page, I would like to move the page back to the top with a button click. The user clicks the button, and I do validation. The error message is at the top of the page, and the button is at the bottom of the page. If something is invalid, then I want to send the user scroll back to the top of the page so they can see the error message.

How can I do this? I don't want to use java-script, unless I have to. Is there away to do this in C# from the code behind?

I have tried this:

ScriptManager.RegisterStartupScript(Page, this.GetType(), "ScrollPage", "scrollToTop();", true);

At run time I get the error: 0x800a1391 - JavaScript runtime error: 'scrollToTop' is undefined

I have a textbox that a user inputs time 24:00 format.


This is the jquery I have to mask that function.

For example if user inputs:

1300 the mask will turn this into 13:00 This works great!

The problem results from when a user puts something like this:

"4:56" the mask will turn that into "45:6" (i would like the mask to pad the left with a zero so instead it's like this: 04:56)

or if the user inputs:

45:6 the mask won't do anything, but I would like it to do this => 45:60 and pad the right with a zero.

Thank you for your assistance!

Im trying to create VM's from a template in my ASP.NET MVC web application. So I wrote an action is structured in 4 steps (I added some comments to make it more understandable)

public ActionResult QuickCreateVM(string VirtualMachineName, string OSImage, string Username, string Password)
    string Location = "North Europe";
    string StorageAccountName = "azuremanagersharepoint"; 

        ComputeManagementClient client = new ComputeManagementClient(cloudCredentials);
        string vmName = VirtualMachineName;

        //STEP1:Create Hosted Service 
        //Azure VM must be hosted in a  hosted cloud service. 
        createCloudService(vmName, Location);

        //STEP2:Construct VM Role instance 
        var vmRole = new Role();
        vmRole.RoleType = VirtualMachineRoleType.PersistentVMRole.ToString();
        vmRole.RoleName = vmName;
        vmRole.Label = vmName;
        vmRole.RoleSize = VirtualMachineRoleSize.Small;
        vmRole.ConfigurationSets = new List<ConfigurationSet>();
        vmRole.OSVirtualHardDisk = new OSVirtualHardDisk()
            MediaLink = getVhdUri(string.Format("{0}", StorageAccountName)),
            SourceImageName = OSImage

        ConfigurationSet configSet = new ConfigurationSet
            ConfigurationSetType = ConfigurationSetTypes.WindowsProvisioningConfiguration,
            EnableAutomaticUpdates = true,
            ResetPasswordOnFirstLogon = false,
            ComputerName = vmName,
            AdminUserName = Username,
            AdminPassword = Password,
            InputEndpoints = new BindingList<InputEndpoint> 
                new InputEndpoint { LocalPort = 3389, Port = 3389, Name = "Remote Desktop", Protocol = "TCP", EnableDirectServerReturn = true }


        vmRole.ResourceExtensionReferences = null;

        //STEP3: Add Role instance to Deployment Parmeters 
        List<Role> roleList = new List<Role>() { vmRole };
        VirtualMachineCreateDeploymentParameters createDeploymentParams = new VirtualMachineCreateDeploymentParameters
            Name = vmName,
            Label = vmName,
            Roles = roleList,
            DeploymentSlot = DeploymentSlot.Production

        //STEP4: Create a Deployment with VM Roles. 
        client.VirtualMachines.CreateDeployment(vmName, createDeploymentParams);
    catch (CloudException e)

        throw e;
    catch (Exception ex)
        throw ex;

    return View("Panel");

My problem: It seems like my VM has no endpoint. Although the ConfigurationSet was configured correctly. So, in my code I say

new InputEndpoint { LocalPort = 3389, Port = 3388, Name = "Remote Desktop", Protocol = "TCP", EnableDirectServerReturn = true }

But in the azure portal No endpoints are configured So I'm not able to start the Vm. Has anyone an idea what I'm missing? Or are there any good tutorials to this topic? Thank you in advance

I'm new to playing videos on the web, but here's my situation.

I'm creating a website to market a product. I've been given a .wmv video file to play when a button is clicked. I'm using ASP MVC 5, and have access to the latest and greatest of my choosing.

My questions are:

  1. Am I going to need more file types for the same file so it's playable across multiple devices? IE: iOS, PC, Android? If so, what types should I ask for?
  2. Assuming I have a few file types provided, are there recommended approaches for playing a video in a pop-up/modal window?

Here's my solution structure:

  • Project A (Class Library): Main Functionality API Controllers
  • Project B (Class Library): Additional Functionality API Controllers
  • Project C (ASP.NET Web): Web API Host (just contains Global.asax and configuration code)
  • Project D (MS Test): Web API Integration tests

In my Project D I have test cases for all controllers in Project A and they all run fine. However, for the integration test case that I wrote for a controller in Project B I keep getting the error 404: No type was found that matches the controller named 'notifications'.

What I tried:

  • I initially had attribute routing and thought there might have been a problem, with attribute routing, and removed the attributes and changed my URL to match the default route, and I still have the same problem.
  • I thought the assembly wasn't being loaded as there are no direct usage, and hence I forced the type to be loaded using a call to typeof(NotificationsController) and ran an assertion on the return value.
  • I tested this with a regular browser and I am able to get the result for attribute routing as well.
  • I checked NotificationsController is in fact deriving from ApiController (through another base class of course, but that is the same base class for all my API controllers)

My test code initialization is like below:

var config = new HttpConfiguration();
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;


HttpServer = new HttpServer(config);

My Global.asax code in Project C is like below:


In my WebApp.Start method, I do have a call to config.EnsureInitialized(). I am not sure if it is of any consequence, but I am using Unity DI and have ensured that Unity configuration is also happening in the flow.

What might I be missing at this point? How do I proceed to debug this further. Any help on this is greatly appreciated.

I'm building an application, one of the requirements is to use AJAX to constantly pull information from an online xml dataset, and get one of the element value, the value is a percentage and I need to make a progress bar out of it .

The url I use for requesting my xml data is something like :

someserver/xml?xpath=(//someattribute) I get a the value I want, but currently I'm using http request in C# to do it and it is a one time thing, my question is can I use AJAX to pull this type of data frequently ?(like every 3-5 seconds) ?

Another question is about the Query progress bar, I tried the sample here code but it does not display anything on my html file:

I have repeater control which is being exported to a pdf doc where i am able to control the number of rows per page ( i.e 2 per page) so if there are 6 records from the Sql Datasource there would be 3 pages when exporting to pdf. Now i would like to dynamicallly page number them...Is there a way to achieve it through the repater control items..

Say I want this on each page Page 1 of 3 on first page, Page 2 of 3 on second on...

Can someone please guide me on this?

Thank you

Can't figure out what the problem is. Can you please help me out?

I have an application in which I am using multiple kendo charts. My requirement is to show the remote data using aspx web methods. But I am not getting any data in kendo charts.

Here is my code,

var dataSource = new{
type: "json",
  transport: {
    read: {
      type: "POST",
      url: "Commercial.aspx/FetchCounts",
      contentType: 'application/json; charset=utf-8',
      datatype: "json"
          }, //read
          parameterMap: function (options) {
          return $.parseJSON(options);
       serverFiltering: false,
       serverSorting: false,
       schema: {
             data: "d",
               model: {
                 fields: {
                  current: { type: "string" },
                  target: { type: "string" }
    function createSparklines() {
         legend: {
         visible: false
         dataSource : dataSource,
         series: [{
            type: "bullet",
            currentField: "current",
            targetField: "target",
            target: {
                 color: "#e13c02"
            categoryAxis: {
                majorGridLines: {
                visible: false
            majorTicks: {
                visible: false
                 valueAxis: [{
                      plotBands: [{
                                from: 0, to: 8000, color: "#ccc", opacity: .3
                  majorGridLines: {
                                visible: false
                  min: 0,
                  max: 8000,
                  majorUnit: 2000,
                  minorTicks: {
                       visible: true
                  tooltip: {
                      visible: false,
                      template: "Goal: #= # <br /> Current: #= value.current #"
           $(document).bind("kendo:skinChange", createSparklines);

The method "FetchCounts" returns the following data : [{"current":5000,"target":7500}]

Please let me know what I am missing. Any ideas will be appreciated.


i have a text box and i need validate it with regular expression at least two words in text box, and not contain spaces in the first character. pls give me a regular expression to validate my textbox

Currently I am using


<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
    controltovalidate="TextBox1" validationexpression="^((\b[a-zA-Z]{2,40}\b)\s*){2,}$" 
    errormessage="at least two words"></asp:RegularExpressionValidator>
<asp:Button ID="Button1" OnClick="btnClick" runat="server" Text="Button" />

I'm working on my first from-scratch back end project. Forgive my ignorance.

I have a page that's filled by data returned from an API. I'm connecting to the API successfully using SoapClient, but I'm unable to successfully parse the results.

How can I echo Status in the object below?

The returned object is:

stdClass Object(
    [LoginResult] => {
            "Message":"Access Denied"},

My code is:


The error I receive is:

Undefined property: stdClass::$Result.