If you create a custom Exception that overrides the virtual property Message with something like this:

public class GrossException : Exception
{
    public GrossException() : base("Eww, gross") { }
}

public class BarfException : GrossException
{
    public override string Message { get; } = "BARF!!";
}

Then, when sending BarfException using JSON.NET through ASP.NET, the Message property will contain

"Eww, gross"

Instead of the overridden value. I believe this is related to the fact that Exception implements ISerializable, but since the Message property is virtual, should I not be allowed to override it like this and still have it work?

Is there a proper way to implement Exception and be able to override the Message property and still have it work?

I have two TextBox fields in a web form that are validated as dates using the CustomValidation element. An excerpt of how I set this up is as follows (includes the fields and the Javascript validator):

<script type="text/javascript">
    function dateParam1(sender, args)
    {
        var dt = document.getElementById('ctl00_ContentPlaceHolder1_txt01');


        args.IsValid = dt.value.length > 0 ? (/([1-9]|0[1-9]|1[012])[- \/.]([1-9]|0[1-9]|[12][0-9]|3[01])[-\/.](19|20)\d\d/.test(dt.value) ? true : false) : true;
    }

    function dateParam2(sender, args)
    {
        var  dt = document.getElementById('ctl00_ContentPlaceHolder1_txt02');


        args.IsValid = dt.value.length > 0 ? (/([1-9]|0[1-9]|1[012])[- \/.]([1-9]|0[1-9]|[12][0-9]|3[01])[-\/.](19|20)\d\d/.test(dt.value) ? true : false) : true;
    }
</script>
<asp:Panel ID="pnl01" runat="server" Width="600px" Visible="False">
    <table>
        <tr valign="middle">
            <td width="250px" align="right">
                 <asp:Label ID="lbl01" runat="server" ></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txt01" runat="server" MaxLength="50"></asp:TextBox>
                <asp:CustomValidator ID="cvP01" runat="server" ErrorMessage="(mm/dd/yyyy)" ValidateEmptyText="True" ControlToValidate="txt01" ClientValidationFunction="dateParam1" ></asp:CustomValidator>
            </td>
            <td>
                <asp:Label ID="lbl01a" runat="server" Font-Size="X-Small" ForeColor="#000066" ></asp:Label>
            </td>
        </tr>
    </table>
</asp:Panel>
<asp:Panel ID="pnl02" runat="server" Width="600px" Visible="False">
    <table>
        <tr valign="middle">
            <td width="250px" align="right">
                <asp:Label ID="lbl02" runat="server" ></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txt02" runat="server" MaxLength="50"></asp:TextBox>
            </td>
            <td>
                <asp:Label ID="lbl02a" runat="server" Font-Size="X-Small" ForeColor="#000066" ></asp:Label>
                <asp:CustomValidator ID="cvP02" runat="server" ErrorMessage="(mm/dd/yyyy)" ValidateEmptyText="True" ControlToValidate="txt02" ClientValidationFunction="dateParam2" ></asp:CustomValidator>
            </td>
        </tr>
    </table>
</asp:Panel>

As you can see, I have two separate validation elements and functions for each textbox. However, although both validations correspond to separate Text Boxes, the validation being done to both of them are exactly the same (i.e. evaluating how the dates should look and what they contain)

My question is: is there a way to make a single validation function that could validate all specified text boxes as dates, not only on this page, but across the entire application?

I have attempted to implement a global Javascript function by adding it to the Master file. This works but it requires the specific ID of the element you are trying to validate. It is possible to give every date text box throughout the application the same ID, but this would not work if you have two date fields on the same page. Is it possible to get the value passed to the function through either sender or args?

If it makes any difference, my code-behind is written in C#.

I am making a website that needs a very simple comment system, and I've seen many tutorials and how to's about doing that, but I would like the user input to be written in a text file, and after that be introduced in the html of the site from that file, because I'm not very good with databases and I think a text file would be easier to manage for my task.How could I do that?

So i've started with ASP.NET and i need to pass value from one textbox (one webform) to another.

On my start page, i have 3 different textboxes and 3 buttons. On click, each button opens same pop-up window. In this window, there is another textbox and button.

Now when i type data in textbox and hit "send", the pop-up needs to close and send data to textbox that opened up pop-up window

I've managed to get my data from the pop-up window to textbox on my first button...but if i open up pop-up with another button, it still sends data to the same textbox as before, instead of second.

This is my code

Tryout.aspx

protected void btnClose_Click(object sender, EventArgs e)
    {
        Session["value"] = textBox1.Text;
        Response.Clear();
        Response.Write("<script>window.close();</script>");
        Response.Flush();
        Response.End();
    }

Default.aspx

protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["value"] != null)
        {
            textBox1.Text = Session["value"].ToString();
        }
    }

What i want - in picture (ofcourse data gets sent from pop-up window)

enter image description here

any suggestions?

Thanks!

Although my code compiles and runs I am plagued by little red squiggly lines. For example, Html.BeginForm is not recognised. Although, if I type "Html." then intellisense does suggest some other methods such as Checkbox and DropDownList.

Other underlines include model and ViewBag.

I've got a reference to MVC 5.2.3.0 and the System.Web.Mvc namespace is in my web.config

This has been going on for months and is wasting a lot of my time. I'm sure it has something to do with the versions of packages I have installed but I don't understand it enough to be able to troubleshoot it.

I've rebuilt my computer, reinstalled Visual Studio 2013, and copied my code back (in chunks to try to isolate the problem) but I'm getting nowhere fast.

Can anyone help me get to the bottom of this before I switch careers?

I want to hide a radiobutton. I try it like this:

  @if (GetBoolean("bdCanOrderOnAccount"))
                                            {
                                                <div class="control-group">
                                                    <input type="radio" value="PAY1" id="EcomCartPaymethodID_PAY1a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY1")) { <text> checked="checked" </text>           }>
                                                    <label for="EcomCartPaymethodID_PAY1a" class="pull-left radio-label">@Translate("choosepaymentmethodebankaccount", "Betaal op rekening")</label>
                                                </div>
                                            }
                                        <!--<div class="control-group">
                                            <input type="radio" value="PAY2" id="EcomCartPaymethodID_PAY2a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY2")) { <text> checked="checked" </text>          }>
                                            <label for="EcomCartPaymethodID_PAY2a" class="pull-left radio-label">@Translate("choosepaymentmethodeideal", "Betaal online via iDeal")</label>
                                        </div>-->


                                        <div class="control-group">
                                            <input type="radio" value="PAY3" id="EcomCartPaymethodID_PAY3a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY3")) { <text> checked="checked" </text>           }>
                                            <label for="EcomCartPaymethodID_PAY3a" class="pull-left radio-label">@Translate("choosepaymentmethodepickup", "Betaal bij afhalen")</label>
                                        </div>
                                    </div>

                                </div>

                        <script>
                                            $(function () {                                                 
                                              var rbtn = document.getElementById('EcomCartPaymethodID_PAY3a');
                                              document.getElementById('EcomCartPaymethodID_PAY3a').style.visibility = 'hidden';

                                              });
                                            </script>

So if I do a alert('hoi') in the script then I see the hoi message. But the radio button is not hidden.

How can that be?

Thank you

But if I do it like this:

<div class="hallo">
                                        <div class="control-group">
                                            <input type="radio" value="PAY3" id="EcomCartPaymethodID_PAY3a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY3")) { <text> checked="hecked" </text>           }>
                                            <label for="EcomCartPaymethodID_PAY3a" class="pull-left radio-label">@Translate("choosepaymentmethodepickup", "betaal bij afhalen")</label>
                                        </div>
                              </div>

and this:

<script>
                                            $(function () {                                              
                                              document.document.getElementsByClassName('hallo').style.visibility = 'hidden';

                                              });
                                            </script>

it doesnt hide

I have a DropdownListFor field that you will select a country name:

        <div class="form-group">
        @Html.LabelFor(model => model.CountryCode, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.DropDownListFor(model => model.CountryCode, null, new { @class = "form-control" })
            @Html.ValidationMessageFor(model => model.CountryCode, "", new { @class = "label label-danger" })
        </div>
    </div>

in the view will show the governorate field if the user select Egypt - EG country code - So my Script.js:

    $("input[name='Address.CountryCode']").change(function () {

    if ($(this).val() == "true") {
        $("#EgyptianCitizen").slideDown();
    }
    else {
        $("#EgyptianCitizen").slideUp();
    }
});

And the HTML Field for the Governorate:

    <div class="form-group" id="EgyptianCitizen" style='@((Model != null && Model.CountryCode=="EG") ? "display: block;" : "display: none;")'>
    @Html.Label("GovernorateID", "Governorate", htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.DropDownListFor(model => model.GovernorateID, null, new { @class = "form-control" })
        @Html.ValidationMessageFor(model => model.GovernorateID, "", new { @class = "label label-danger" })
    </div>
</div>

But still not working...

In order to support C# 6 in our Razor views on MVC5, we turned on the Roslyn compiler platform via web.config:

<system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
    </compilers>
</system.codedom>

However, after production deployments, each view/controller appears to have a noticeable "First Load" delay that is worse than without this compiler being enabled.

Importantly, this delay is in addition to the regular JIT delay you get from a new site being deployed. Pages are noticably slower, while it appears VBCSCompiler.exe runs in the background to "further compile" these pages.

Is there a best practice for pre-compiling/optimizing this situation to eliminate the first-load runtime delay post deployment? Ideally VBCSCompiler.exe is not running after a deployment occurs, and is performed at build-time.

I've seen mentions of aspnet_compiler.exe and have come across StackExchange.Precompilation (see https://blog.stackoverflow.com/2015/07/announcing-stackexchange-precompilation/) and wonder if this is the right fix.

Does anyone have any experience with this particular problem? Thank you.

I have a dropdown in my contents like this https://snag.gy/OxgeoA.jpg where I have got 3 labels:value options.
In my razor template I would like to get the label instead of the value.
Here is how I can get the value (0,1,2)

@Content.Dropdown

How can I get Labels please? (Negativo,Positivo,Non Testato).
Thanks you

I have several checkboxes: a- bezorgen b- afhalen.

if Afhalen is checked then the checkbox betaal op rekening has to be checked.

But now only the first time when afhalen is checked the radio button betaal op rekening is checked. But if you go to bezorgen and then back to afhalen the radio button betaal op rekening is not checked anymore. But it has to be checked.

I have this:

    @if (GetBoolean("bdCanOrderOnAccount"))
{
string ischecked = GetString("User.bdDefaultPickupOrDelivery.Value").Equals("afhalen") ? "checked" : null;
<div class="control-group">
  <input type="radio" value="PAY1" id="EcomCartPaymethodID_PAY1a" name="EcomCartPaymethodID"  class="pull-left"  @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY1")){ 
  <text> checked="checked" </text>
  }>
  <label for="EcomCartPaymethodID_PAY1a" class="pull-left radio-label">@Translate("choosepaymentmethodebankaccount", "Betaal op rekening")</label>
</div>
}
<!--
  <div class="control-group">
    <input type="radio" value="PAY2" id="EcomCartPaymethodID_PAY2a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY2")) { <text> checked="checked" </text>          }>
    <label for="EcomCartPaymethodID_PAY2a" class="pull-left radio-label">@Translate("choosepaymentmethodeideal", "Betaal online via iDeal")</label>
  </div>
                                    -->
<div class="control-group">
  <input type="radio" value="PAY3" id="EcomCartPaymethodID_PAY3a" name="EcomCartPaymethodID" class="pull-left" @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY3")) { 
  <text> checked="checked" </text>
  }>
  <label for="EcomCartPaymethodID_PAY3a" id='labelPay' class="pull-left radio-label">@Translate("choosepaymentmethodepickup", "betaal bij afhalen")</label>
</div>
</div>
@if (GetBoolean("bdCanOrderOnAccount")){
<script>
  $(function () {                                
  $('#EcomCartPaymethodID_PAY3a').parent().hide();  
  $("#EcomCartPaymethodID_PAY1a").prop('checked', true); 
  //alert('test')                          



    });





</script>                             
}
<script>
  $(function () {       
  if ($("#levering-optie-afhalen").prop("checked")) {
                    alert('true');
  $("#EcomCartPaymethodID_PAY1a").prop('checked', true); 

       alert('false');

  }
  });
</script>

so with this:

   <script>
  $(function () {       
  if ($("#levering-optie-afhalen").prop("checked")) {
                    alert('true');
  $("#EcomCartPaymethodID_PAY1a").prop('checked', true); 

       alert('false');

  }
  });
</script>

I check if the radiobutton afhalen is been checked.

Thank you

NIels

so if this is checked:

 <input type="radio" name="levering-opties" id="levering-optie-afhalen" value="afhalen" checked="@ischecked">

Then this also has to been checeked:

<div class="control-group">
  <input type="radio" value="PAY1" id="EcomCartPaymethodID_PAY1a" name="EcomCartPaymethodID"  class="pull-left"  @if (GetString("Ecom:Order.PaymentMethodID").Equals("PAY1")){ 
  <text> checked="checked" </text>
  }>
  <label for="EcomCartPaymethodID_PAY1a" class="pull-left radio-label">@Translate("choosepaymentmethodebankaccount", "Betaal op rekening")</label>
</div>

I have a NOPCommerce plugin where one of my views displays a list of images. On clicking an image I wish to open a modal dialog. The dialog receives it's body from a Partial View. The problem I have is that the Dialog screen isn't popping up. The HTML from the Partial View is however received from the GET-request (unless if the debugger is lying).

Due to the HTML showing up in the debugger and after navigating to it I believe the Routing is correct. With that said though I have no idea why my JQuery dialog doesn't popup. Any ideas as to why are welcome.

Prehaps an important note: After the script ran and the Modal popup should display, the main view (the one with the images) gets slightly changed. I've added 2 images to showcase the change. Edit: This happens when the dialog enters the open function. So on the line:

var viewToOpen = "/uploadphotobook/editor";

TopBar Before Image Click

TopBar After Image Click

Javascript

function loadOnClickEventsToImages() {
    var images = document.getElementsByClassName("imageContainer");
    console.log("Images loaded: " + images.length);
    for (var i = 0; i < images.length; i++) {
        var img = images[i];
        img.addEventListener("dblclick", function () {
            alert("Image Clicked");
            console.log("Image clicked: " + img);
            dialogFunction(img);
        })
    }
}

function dialogFunction(image_param) {
    //var outsideWidth = $("#outsideContentDiv").width;
    $("#editor-dialog").dialog({
        autoOpen: true,
        //width: outsideWidth * 80 / 100,
        width: 800,
        resizable: false,
        modal: true,
        open: function () {
            var viewToOpen = "/uploadphotobook/editor";
            console.log("Opening EditorView: " + viewToOpen);
            $(this).load(viewToOpen);
        },
        buttons: {
            "Close": function () {
                $(this).dialog('close');
            }
        }
    })
}

RouteProvider

public void RegisterRoutes(RouteCollection routes)
{
        routes.MapRoute("Plugin.Nextprint.Photobook.TextEditor",
                "uploadphotobook/editor",
                new { controller = "NextprintPhotobook", action = "DisplayTextEdit" },
                new[] { "Nop.plugin.Nextprint.Photobook.Controllers" }
        );
}

Controller

public ActionResult DisplayTextEdit()
{
    return PartialView("~/Plugins/Nextprint.Photobook/Views/NextprintPhotobook/EditorView.cshtml");
}

HTML (Positioned just above the footer section)

@section outsideContentDiv {
    <div id="preparing" style="display: none;">
        <h2>Uw fotoboekje word voorbereid, even geduld a.u.b.</h2>
        <div id="preparingSpinner">&nbsp;</div>
    </div>

    <div id="editor-dialog" title="Edit Album"></div>
}

The PartialView only holds standard HTML items.

I am learning ASP.NET from book Pro ASP.NET 4.0 but I have stucked on adding CartController and Views/Cart/Index.cshtml

I have added something like this:

public class CartController : Controller
    {
        private IProductRepository repository;

        public CartController(IProductRepository repo)
        {
            repository = repo;
        }

        public ViewResult Index(string returnUrl)
        {
            return View("Index", "~/Views/Shared/_Layout.cshtml", new CartIndexViewModel
            {
                Cart = GetCart(),
                ReturnUrl = returnUrl
            });
        }

        public RedirectToRouteResult AddToCart(int productId, string returnUrl)
        {
            Product product = repository.Products
            .FirstOrDefault(p => p.ProductID == productId);

            if (product != null)
            {
                GetCart().AddItem(product, 1);
            }
            return RedirectToAction("Index", new { returnUrl });
        }
        private Cart GetCart()
        {
            Cart cart = (Cart)Session["Cart"];
            if (cart == null)
            {
                cart = new Cart();
                Session["Cart"] = cart;
            }
            return cart;
        }
       }
     }

Then I have added to my Cart->Index action view (right click->Add View), like this:

@model SportsStore.WebUI.Models.CartIndexViewModel
@{
ViewBag.Title = "Sklep sportowy: Twój koszyk";
}

<h2>Twój koszyk</h2>
<table width="90%" align="center">
    <thead>
        <tr>
            <th align="center">Ilość</th>
            <th align="left">Produkt</th>
            <th align="right">Cena</th>
            <th align="right">Wartość</th>
        </tr>
    </thead>
    <tbody>
        @foreach(var line in Model.Cart.Lines) {
        <tr>
            <td align="center">@line.Quantity</td>
            <td align="left">@line.Product.Name</td>
            <td align="right">@line.Product.Price.ToString("c")</td>
            <td align="right">@((line.Quantity * line.Product.Price).ToString("c"))</td>
        </tr>
        }
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3" align="right">Razem:</td>
            <td align="right">
                @Model.Cart.ComputeTotalValue().ToString("c")
            </td>
        </tr>
    </tfoot>
</table>
<p align="center" class="actionButtons">
    <a href="@Model.ReturnUrl">Kontynuuj zakupy</a>
</p>

In my Product Summary on the page I have a button that adds Product to Cart and then redirects to this localhost:port/Cart/Index page. Here is this navigation button:

@model SportsStore.Domain.Entities.Product

    <div class="item">
         <h3>@Model.Name</h3>
         @Model.Description

         @using(Html.BeginForm("AddToCart", "Cart")) {
            @Html.HiddenFor(x => x.ProductID)
            @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
            <input type="submit" value="+ Dodaj do koszyka" />
         }
         <h4>@Model.Price.ToString("c")</h4>
    </div>

The problem is that the Cart works perfectly well but it's view isn't embedded in main layout /Shared/_Layout.cshtml. It just appear as separate page that doeasn't include any html headers or body stuff, just content section of the website.

The github project of the same example I have found is done exactly the same way as the main Visual Studio project. https://github.com/akatakritos/SportsStore

I have checked the book code listings and I cannot find any errors. Why it doesn't appear correctly as the part of the main layout? But is in separate view!

Thx for any help.

EDIT:

I have Views/Shared/_ViewStart.cshtml

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

I seem to have lost all my ASP.NET MVC 5 templates when creating a new project, and when I try to add a view to an existing MCV 5 site, this option, which used to be there:

"MVC 5 View Page with (Layout Razor)."

Is no longer there.

I went to https://www.asp.net/mvc/mvc5 and it says to download Visual Studio 2015 community edition , or MVC 5 support for VS 2013. I am using VS 2015 Profession with update 2. I uninstalled update 3 thinking that's what did it.
Thanks,

enter image description here

I am trying to change my table row class name dynamically from my model in datatable to highlight the lines with different color based on my status.

My code is working, and class name is being set. But the css style to table row is applied only to odd rows.

I want to apply the css style to all my rows based on my Model - OverAllStatus result. I also checked, that for all rows in my list - Model.InvoiceDetailsList there is over all status. And, for all those overall status results, i have css style.

My HTML - DataTable code:

<table id="tblDashBoardInvoices" class="table table-striped table-bordered" style="max-width: 100%">

    <thead>
        <tr style="background-color: #222222; color: white; font-size: small; align-content: center">
            <th>VPL ID</th>
            <th>From</th>
            <th>To</th>
            <th>Po Number</th>
            <th>Po Qty</th>
            <th>Invoice Number</th>
            <th>Invoice Qty</th>
            <th>Invoice Amount</th>
            <th>Currency</th>
            <th>Invoice Date</th>
            <th>Packingslip Number</th>
            <th>Payment Term</th>
            <th>Invoice File Name</th>
            <th>System File Name</th>
            <th>Shipment Date</th>
            <th>AP ID</th>
            <th>AP Status</th>
            <th>Traffic ID</th>
            <th>Traffic Status</th>
            <th>Wear House Status</th>
            <th>Overall Status</th>
            <th>By</th>
            <th>Edit</th>
        </tr>

    </thead>
    <tbody>
        @foreach (var row in Model.InvoiceDetailsList)
        {
            <tr class="@row.OverAllStatus">
                <td>@row.VplTransID</td>
                <td>@row.SubmittedBy</td>
                <td>@row.SubmittedTo</td>
                <td>@row.PoNumber</td>
                <td>@row.PoQty</td>
                <td>@row.InvoiceNumber</td>
                <td>@row.InvoiceQty</td>
                <td>@row.InvoiceAmount</td>
                <td>@row.InvoiceCurrency</td>
                <td>@row.InvoiceDate</td>
                <td>@row.TrackingId</td>
                <td>@row.PaymentTerm</td>
                <td>@row.SuppFileName</td>
                <td>@row.SysFileName</td>
                <td>@row.ShipmentDate</td>
                <td>@row.ApTransactionId</td>
                <td>@row.ApStatus</td>
                <td>@row.TrafficTransactionId</td>
                <td>@row.TrafficStatus</td>
                <td>@row.WhStatus</td>
                <td>@row.OverAllStatus</td>
                <td>@row.UserName</td>
                <td><a id="btnEdit" href="#" onclick="btnEditClick(@row.KeyId,'@row.VplTransID @row.ApTransactionId @row.TrafficTransactionId')"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a></td>
            </tr>
        }
    </tbody>
</table>

My CSS:

<style>
    .Saved {
        background-color: #ADD7F2;
    }

    .InProgress {
        background-color: #F1EA55;
    }

    .Cancelled {
        background-color: #F93A07;
    }

    .Completed {
        background-color: #CDEA6A;
    }
</style>

Result: enter image description here

So I basically have sharepoint asp.net page and button that does this copy operation

System.IO.File.Copy("\\\\server.name\\folder\\folder\\123.txt", Server.MapPath("\\\\WebserverTempFileCopy\\123.txt"), true);

The problem is if I do this from development environment it works okay, but if I try to do this from outside 403 FORBIDDEN error pops up, basically it can't reach "\\server.name\folder\folder\123.txt" for some reason and I have no idea why.

Request is made by web server, right? But it has access when I'm trying this from development environment, even if outside user is making request he also has access for that fileserver, so I have no idea where to search for error.

I'm new with asp.net and sharepoint, so maybe this is simple and stupid question, but thanks anyway.

I am currently using SignalR for chat. I have a form and the user will load a specific order into the form. The scenario is that other staff members may search that order number and therefore i want only those people to be in the chat. Currently if you load the site everyone is in a single hub called ChatHub.

ChatHub.cs:

public class ChatHub: Hub {
 public void Send(string name, string message) {
  // Call the addNewMessageToPage method to update clients.
  Clients.All.addNewMessageToPage(name, message);
 }
}
}

Chat.cshtml:

@section scripts {
    <!--Script references. -->
    <!--The jQuery library is required and is referenced by default in _Layout.cshtml. -->
    <!--Reference the SignalR library. -->
    <script src="~/Scripts/jquery.signalR-2.0.3.min.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="~/signalr/hubs"></script>
    <!--SignalR script to update the chat page and send messages.-->
    <script>
        $(function () {
            // Reference the auto-generated proxy for the hub.
            var chat = $.connection.chatHub;
            // Create a function that the hub can call back to display messages.
            chat.client.addNewMessageToPage = function (name, message) {
                // Add the message to the page.
                $('#discussion').append(htmlEncode(name)
                    + ':' + htmlEncode(message) + '\n');
            };
            // Get the user name and store it to prepend to messages.

            //$('#displayname').val(prompt('Enter your name:', ''));
            // Set initial focus to message input box.
            $('#message').focus();
            // Start the connection.
            $.connection.hub.start().done(function () {
                $('#sendmessage').click(function () {
                    // Call the Send method on the hub.
                    chat.server.send($('#displayname').val(), $('#message').val());
                    // Clear text box and reset focus for next comment.
                    $('#message').val('').focus();
                });
            });
        });
        // This optional function html-encodes messages for display in the page.
        function htmlEncode(value) {
            var encodedValue = $('<div />').text(value).html();
            return encodedValue;
        }
    </script>
}
<script>

I have tried to add the following:

<script>
$(function () {
    var chat = jQuery.connection.chat;

    chat.addMessage = function (message, room) {

        if ($('#currentRoom').val() == room) {
            $('#messagesList').append(message);
        }
    };


        chat.send($('#textboxMessage').val(), $('#currentRoom').val());
        $('#textboxMessage').val("");


    $.connection.hub.start();
});
</script>

I am trying to work out a way of getting multiple hubs or chat rooms based on a user loading an order.

I am unable to see report viewer control in UI post button click and also in aspx I am getting the below error message in design view.

Error Creating Control - ReportViewer1Failed to create designer 'Microsoft.Reporting.WebForms.ReportViewer, Microsoft.ReportViewer.WebForms, 
Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExportReportToPDF.aspx.cs"
Inherits="ExportReportss.ExportReportToPDF" EnableEventValidation="false" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
    <br />
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Button ID="btnGetReport" runat="server" Text="GetReport"     OnClick="btnGetReport_Click" />
        <rsweb:ReportViewer ID="ReportViewer1" runat="server">
        </rsweb:ReportViewer>
    </div>
</form>
</body>
</html>

Code Behind:

public partial class ExportReportToPDF : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnGetReport_Click(object sender, EventArgs e)
    {
        try
        {
            ReportViewer1.ProcessingMode = ProcessingMode.Remote;
            ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://Modile/Reports");
            ReportViewer1.ServerReport.Refresh();
        }
        catch (Exception ex)
        {

        }
    }        
}

In web.config file I have added the below lines under system.webServer tag

<handlers>
  <add name="ReportViewerWebControlHandler" preCondition="integratedMode"     verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>

I don't have access to the URL (http://Modile/Reports) I am using here and not sure if that is the issue. Can anyone help me this one?

I have an ASP.NET Website running on IIS 8 on Windows Server 2012. The website is a single site - e.g., www.example.com - that is used by different companies. Each company has several users on the site.

Currently, we require each user on the site to create an account on the website and that's how they authenticate.

Some companies want to have their users authenticate via Shibboleth, however. I have installed Shibboleth SP on Windows in the past, but from what I can tell it's designed so that there is a single Shibboleth IdP for the entire site. In this case, we'd need to be able to have, say, users A and B authenticate with one Shibboleth IdP while users X, Y and Z need to use a different Shibboleth IdP.

Is this configuration possible for Shibboleth SP on Windows? Are there any good examples/walkthroughs exploring this scenario in particular?

I am trying to set a value to an input text field but I get the error Cannot set property 'value' of null

I have set the name and ID to hdnContactID:

<input runat="server" type="text" name="hdnContactID" id="hdnContactID" style="display:none"/>

But then in the javascript code when I try to set a value to hdnContactID I get the error:

document.getElementById('hdnContactID').value = result.ID; 

result.ID is returning a number but how is it not finding hdnContactID?

I use the following class to exchange JSON data over two ASP.NET services :

[DataContract]
public class Filter
{
   [DataMember]
   public string Name {get; set;}

   [DataMember]
   public FilterOperator Operator {get; set;}

   [DataMember]
   public object Value {get; set;}    
}

Here is the problem : if I set a DateTime inside Value, it will be deserialized as string :

Value = "/Date(1476174483233+0200)/"

This is probably because deserializer has no clue to know what was the type of the value when serialized initially :

JSON = {"Value":"\/Date(1476174483233+0200)\/"}

As explained here, DataContractJsonSerializer supports polymorphism, with the help of the __type property.

I have tried to add [KnownType(typeof(DateTime))] attribute on the top of the class but it does not help.

However if I set a Tuple<DateTime> inside Value property (and the appropriate KnownType attribute on the class), it works (the value it deserialized properly) :

Value = {(10/11/2016 10:49:30 AM)}

Inside JSON, __type is emited

JSON = {
     "Value": {
        "__type" : "TupleOfdateTime:#System",
        "m_Item1" : "\/Date(1476175770028+0200)\/"
     }
}

Is there a way to force DataContractJsonSerializer to emit proper information to serialize/deserialize DateTime properly (which mean I got a DateTime after serialization instead of a string) ?

I have try to set EmitTypeInformation = EmitTypeInformation.Always in DataContractJsonSerializerSettings but it does not help.

I'm beginner in asp.net. My scenario : I have Page1.aspx and a button that redirect to page2.aspx. There is a textbox On page1 and a textbox and a button on page2. I want to show modal page2 and page1 wait for return a value that user typed in page2 and after page2 closed, show it in textbox in page1. I don't know how to wait for closing page2 and how to send the value from page2 and get it in page1 . please guide me . thanks a lot in advance