I want to use clientTemplate to show dropdownList that has to be populated with actual row object child. I am asking if something like this is possible, and "rowObject"´s syntax.

grid:

@(Html.Kendo().Grid<Parameter>(Model)

   .Name("basicParamsGrid")
   .Columns(columns =>
    {
       columns.Bound(c => c.Name);
       columns.Bound(c => c.Value).ClientTemplate(Html.Partial("_parameterDropDown", rowObject).ToHtmlString());

dropDownView

@model Parameter


@(Html.Kendo().DropDownList()
      .Name("valueDrop_" + Model.Name)
      .DataTextField("Value")
      .DataValueField("ConfValue")
      .OptionLabel("PleaseChoose")
      .BindTo(Model.AvailableValues)
      //.ToClientTemplate()

)

I'm following a tutorial: http://www.c-sharpcorner.com/article/comments-system-with-asp-net-mvc-5-and-jquery2/

I have an MVC 5 app that has a main view that loads the 1st partial view when the Comment button is clicked OR a new comment is added. The JavaScript ajax calls the action method that returns that 1st partial view and then dynamically builds that 1st partial view area. Now this 1st partial view has a "Reply to Comment" link that when clicked, the JavaScript ajax calls the action method that returns another partial view - the 2nd. The problem is the JavaScript runs the first time - in the main view (Comment button clicked or Add comment button clicked) but NOT the when the link "Reply To Comment" in the 1st partial view area is clicked.

Why?

The area where the "Reply to Comment" link is, is the 1st partial view that was loaded after I added a comment responding to the post.

enter image description here

For a simple test, I just have an alert in the JavaScript .ready function of the 1st partial view. Nothing else (normally it would have the ajax call for to load the 2nd partial view). However, it does NOT fire off.

Here is the main view that does the JavaScript ajax call to load the 1st partial view. It works fine. It dynamically builds and shows the html area to hold the 1st partial view.

@model IQueryable<Comments.ViewModels.PostsVM>

@{
    ViewBag.Title = "GetPosts";
}

@if (Model != null)
{
    // Loop threw the model to display the posts.
    foreach (var post in Model)
    {
        <div class="panel panel-default" style="width: 80%;">
            @* Panel area. *@
            <div class="panel-body">
                <div class="avatar">
                    <img src="~/Images/avatar.png" class="img-circle" style="width: 60px;" />
                    @* Defaulting to a user to start the posts off. *@
                    <span> <a href="" style="font-weight:bold">Danny</a> </span><br />
                    <p style="margin-left: 60px; margin-top: -19px;">
                        <span class="glyphicon glyphicon-time" aria-hidden="true"></span>
                        <time class="timeago" datetime="@post.PostedDate">@post.PostedDate</time>
                    </p>
                </div>

                @* Post message area. *@
                <div class="postMessage" style="margin-top: 11px; margin-left: 9px;">
                    <span class="label label-warning"> @string.Format("Post #{0}", post.PostID) </span><br />
                    <p class="message">
                        @post.Message
                    </p>
                </div>
            </div>

            @* Panel area - to hold all the comment button. *@
            <div class="panel-footer">
                @* Button. *@
                <button type="button" class="btn btn-default Comment" data-id="@post.PostID" value="Comment">
                    <span class="glyphicon glyphicon-comment" aria-hidden="true"></span> Comment
                </button>
            </div>

            @* The area dynamically built. It will hold the partial view - Shared/_MyComments.cshtml. *@

            @* Add comment area. *@
            <div id="@string.Format("{0}_{1}","commentsBlock", post.PostID)" style="border: 1px solid #f1eaea; background-color: #eaf2ff;">
                <div class="AddComment" style="margin-left: 30%;  margin-bottom: 5px; margin-top: 8px;">
                    <input type="text" id="@string.Format("{0}_{1}", "comment", post.PostID)" class="form-control" placeholder="Add a Comment ..." style="display: inline;" />
                    @* Button. *@
                    <button type="button" class="btn btn-default addComment" data-id="@post.PostID"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span></button>
                </div>
            </div>
        </div>
    }
}

<!-- Internal JavaScript. -->
@section Scripts
{
    <script type="text/javascript">
        $(document).ready(function () {
            // For when clicking the Comment button.
            $('.Comment').on('click', function () {
                var id = $(this).attr("data-id");

                var allCommentsArea = $('<div>').addClass('allComments_' + id);

                // Call the Comments controllers action method to get all the comments related to the post id. Will show a partial view.
                $.ajax({
                    type: 'GET',
                    url: '@Url.Action("GetComments", "Comments")',
                    data: { postId: id },
                    success: function (response) {
                        if ($('div').hasClass('allComments_' + id + ''))
                        {
                            // Remove.
                            $('div[class=allComments_' + id + ']').remove();
                        }

                        // For testing:
                        //console.log(response);

                        // Dynamically building the HTML to hold the comments returned. The area for the Shared/_MyComments.cshtml to be placed.
                        allCommentsArea.html(response);
                        allCommentsArea.prependTo('#commentsBlock_' + id);
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert("Critical Error: something is wrong in the call to GetComments! Status: " + xhr.status + ". Error: " + thrownError.toString() + ". Response Text: " + xhr.responseText);
                    }
                })
            });

            // For when clicking the addComment button. Adding a new comment.
            $('.addComment').on('click', function () {
                var postId = $(this).attr('data-id');
                var commentMsg = $('#comment_' + postId).val();
                var dateTimeNow = new Date();

                // An object.
                var comment = {
                    CommentMsg: commentMsg,
                    CommentedDate: dateTimeNow.toLocaleString()
                };

                // Call the Comments controllers action method to get add a comment related to the post id. Will show a partial view.
                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("AddComment", "Comments")',
                    data: { comment, postId },
                    success: function (response) {
                        $('div[class=allComments_' + postId + ']').remove();

                        // Dynamically building the HTML to hold the comments returned which now includes the added comment.
                        // The area for the Shared/_MyComments.cshtml to be placed.
                        var allCommentsArea = $('<div>').addClass('allComments_' + postId);

                        allCommentsArea.html(response);
                        allCommentsArea.prependTo('#commentsBlock_' + postId);
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert("Critical Error: something is wrong in the call to AddComment! Status: " + xhr.status + ". Error: " + thrownError.toString() + ". Response Text: " + xhr.responseText);
                    }
                });
            });

            jQuery("time.timeago").timeago();
        });
    </script>
}

Here's the 1st partial view whose JavaScript does not fire off:

@* A partial view called from the GetPosts.cshtml JavaScript function. *@
@* Has Internal Javascript.                                             *@

@* ---------------------------------------------------------------------------- *@
@* The @model - in this case the viewModel, contains the data needed here.      *@
@* ---------------------------------------------------------------------------- *@

@model IQueryable<Comments.ViewModels.CommentsVM>

@using Comments.ViewModels;

@if (Model != null)
{ 
    @* Loop threw the model to display the comments. *@
    foreach (CommentsVM comment in Model)
    {
        // A row.
        <div class="row" style="width: 100.3%; border-bottom: 1px solid #d2cece; margin-right: -14px; margin-left: -1px;">
            @* A column. *@
            <div class="col-md-4" style="width: 21%;">
                <div class="userProfil" style="margin-left: 9px; margin-top: 12px;">
                    <img src="~/Images/@comment.Users.ImageProfile" class="img-circle" style="width: 46px; height: 53px; border: 1px solid #bcb8b8;" />
                    <a href="#" style="margin-left: 5px; font-weight: bold; font-size: 13px;"> @comment.Users.UserName </a>
                </div>
            </div>

            @* A column. *@
            <div class="col-md-7" style="width: 60%;">
                <div class="commentDetails">
                    @* Area to hold the comment. *@
                    <p style="margin-top: 27px; font-size: 13px; color: #9c9898;"> @comment.CommentMsg </p>

                    <a href="#" class="Reply" data-id="@comment.CommentID">Reply To Comment</a>

                    <div class="@string.Format("{0}_{1}", "ReplayComments", comment.CommentID)" style="display:none;">
                        @* Area to add a sub comment. *@
                        <div class="ReplayCommentInput" style="margin-left: 3%;  margin-bottom: 5px; margin-top: 8px;">
                            <input type="text" id="@string.Format("{0}_{1}", "inputReplay", comment.CommentID)" class="form-control" placeholder="Add a Comment ..." style="display: inline;" />
                            <button type="button" class="btn btn-default ReplyAddComment" data-id="@comment.CommentID"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span></button>
                        </div>
                    </div>
                </div>
            </div>

            @* A column. *@
            <div class="col-md-1" style="width: 19%;">
                <div class="commentDate">
                    <span class="glyphicon glyphicon-time" aria-hidden="true"></span>
                    <time class="timeago" style="margin-top: 27px; font-size: 13px; color: #9c9898;  margin-left: 4px;" datetime="@comment.CommentedDate">@comment.CommentedDate</time>
                </div>
            </div>
        </div>
    }
}

<script type="text/javascript">
     $(document).ready(function () {
        // For testing:
        alert("here I am");
     });
</script>

Now when the "Reply to Comment" link is clicked in the 1st partial, it is to fire off a JavaScript ajax call to load the 2nd partial view - I have it to just firing off an alert for now. This is when the JavaScript does NOT fire off at all.

I have a simple form, where we need to enter the details and on submission, it hits the controller and return the confirmation message.

My issue is, the submit button never hits Jquery .on submit function. Following is my code.

 <form id="form1" action="" method="post" enctype="multipart/form-data" data-ajax-form class='contact_us'>
                                            <input type="text" name="fname" id="fname" placeholder="Full Name" class="form-control">
                                            <input type="text" name="fphone" id="fphone" placeholder="_____-______" class="form-control">
                                            <input type="email" name="femail" id="femail" placeholder="your@email.com" class="form-control">
                                            <input class="online_deal_form form-control" id="send1" type="submit" value="View Online Quote">
                                        </form>

Following is my jquery code:

 $(document).on("submit","[data-ajax-form]",function(e) {
            e.preventDefault();
            $('#loaderSVG').show();
            var $form = $(this);
            var data = $form.serialize();
// does an ajax call to controller
...
});

Instead of hitting jquery function, it is doing a post-back directly to controller, which gives me a IIS 404 error.

I have multiple forms present on a page with different class names, for that reason I'm using data-ajax-form and handle the submit events.

I don't exactly know what I'm doing wrong.

Any help is appreciated !!

Thank you

Has anyone had any success loading _Layout.cshtml from a physical path before?

Problem: At present, MVC throws an error if you attempt to pass something like C:\dedicated\path\to\layouts\_Layout.cshtml to the Layout property in _ViewStart.cshtml due to the executing page hierarchy ("virtual path expected").

Been doing a bit of research and experimentation with this already and have a couple different "hacks" available as workarounds including deriving from RazorView through replacing ExecutePageHierarchy altogether with RunCompile from the RazorEngine NuGet package (probably best bet).

Curious if anyone has come up with a concrete solution for this.

Thanks!

I want to hot code replace Razor View Code (.cshtml) in my ASP.NET project during runtime so that changes are immediately being reflected in the web browser. This only works exactly one time (!). After that the .cshtml-File is not being recompiled.

Are there any changes that have to be made in Visual Studio?

I am using the following tools:

  • Visual Studio Community Edition 2017 15.4.0
  • .NET 4.7.x
  • Internet Explorer 11
  • Windows 10 Enterprise Edition
  • IIS Express

This question already has an answer here:

Trying to set default focus to the following field, but having trouble. Have tried multiple solutions that seemed straight forward, but none are working and I don't know why since these were all highly upvoted answers for mvc 5.1+

Was trying to do without using javascript or switching it to TextBoxFor()

Below are some of them, have also tried some close variations to these.

Any help would be appreciated. Using mvc 5.2 & razor 3.0

@Html.EditorFor(x => x.FirstName, new { style = "Width:100px" })

//I know the above isn't focus, since I wasn't 100% sure on my syntax, but this doesn't change my width either.

@Html.EditorFor(x => x.FirstName, new { htmlAttributes = new { @class = "form-control" }})

@Html.EditorFor(x => x.FirstName, new { htmlAttributes = new { autofocus = "autofocus" } })

I want to implement a Bootstrap slider where the values increment by 0.01. Also, I should be able to specify the range of values; for example, the user can only select values between 4 and 12, and moving the slider increases the values in the increments of 0.01.

Razor/HTML

<input id="inputRateOfInterest" type="text" />

jQuery

<script src="~/lib/jquery/dist/jquery.js"></script>
<script type="text/javascript">
    $("#inputRateOfInterest").scroll({
        precision: 2,
        value: 8.10
    });
</script>

Output I am not seeing any slider in the output. I am simply getting a textbox where I am able to enter text.

I am new to Bootstrap. I referred to some links that gave me some idea, but I wasn't able to go further. I might be missing something.

I have two applications an MVC website and a Web API. I have configured these applications on two different ports but have also setup ARR Proxy and inbound rules using URL Rewrite to handle requests through Default web site. So the requests based on my conditions for each website is redirected to their respective websites. It was working until I disabled SSL v3.0 on my machine for a server vulnerability test report. It shows error as shown at the bottom. If i enable it, it starts working but I am trying to find a common ground where both works.

Let me know if anymore information is required.

enter image description here

The goal of what i am trying to do is to take a photo and upload it using dropzone (which drop zone is working fine for how i have implemented it) and load it to an NTFS file system. I store the "uploadpath" to my SQL server so i can pull the image faster later. The problem that i am running into is i have no idea how to load my images into Azure File System. Also from what i gather a blob storage isnt quite what i am needing to use since that is based off a type of table storage format which isnt using ntfs.

I have been trying to research this and i have no idea where to actually start... i have read a few articles within MSDN to try to understand it but it seems that everything i keep finding is rather pertaining to BLOB storage.

                foreach (string filename in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[filename];
                fname = file.FileName;
                if (file != null && file.ContentLength > 0)
                {

                    var path = Path.Combine(Server.MapPath("~/uploadeimg"));
                    string pathstring = Path.Combine(path.ToString()); 
                    string filename1 = Guid.NewGuid() + Path.GetExtension(file.FileName);
                    bool isexist = Directory.Exists(pathstring);
                    if (!isexist)
                    {
                        Directory.CreateDirectory(pathstring);
                    }
                    uploadpath = string.Format("{0}\\{1}", pathstring, filename1);
                    file.SaveAs(uploadpath);

As for documentation the following links are what i have read and looked through.

File Uploading to Azure Storage by ASP.NET Webpages https://docs.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files

https://docs.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-dotnet-how-to-use-blobs

I appreciate any assistance that you guys may be able to provide. I am looking to get more experience with this type of programming and i have just decided to play around and see what i can do with it.

I should also note. I can save the files in the area that i host the project and I can retrieve them that way as well. But i am not certain that would be the proper way to go about handling this.

I have a HTML page which has labels with text. When a button is clicked a PDF should be created with the text from the HTML page. I am using itextsharp and have successfully created a PDF but how do I fill it with text from my HTML page.

C# code:

protected void btnPDF_Click(object sender, EventArgs e)
    {

        System.IO.FileStream fs = new FileStream(Server.MapPath("") + "\\" + "FirstPDFdocument.pdf", FileMode.Create);

        Document document = new Document(PageSize.A4, 25, 25, 30, 30);
        // Create an instance to the PDF file by creating an instance of the PDF 
        // Writer class using the document and the filestrem in the constructor.

        PdfWriter writer = PdfWriter.GetInstance(document, fs);
        // Open the document to enable you to write to the document

        document.Open();

        // Add a simple and wellknown phrase to the document in a flow layout manner

        document.Add(new Paragraph("Hello World!"));

        // Close the document

        document.Close();
        // Close the writer instance

        writer.Close();
        // Always close open filehandles explicity
        fs.Close();

    }

Using: Visual Studio 2015, C#, on a Surface Pro 3, running Windows 10 Pro Skill level: novice

I created a personal website and deployed it to Azure hosting. In one of my web forms, I select a type of reference from a DropDownList control (book, article, monograph, etc). Then, I enter several pieces of citation data into TextBox controls. Then I press a Button. All of the TextBox data is written to an XML file. Also, there are a series of if-then statements in the .aspx.cs code behind. Only one of the if-then statements will be true, based upon the DropDownList SelectedItem. So, for example, if SelectedItem is "Monograph" then the text in the TextBoxes will be appended to a string and formatted according to the format for citing to a monograph in a footnote.

.cs exerpts...

string referenceType = ddlType.SelectedItem.Text;
...
if (referenceType == "Monograph")
{
    longCite = "<span style='font-variant:small-caps'>" + author + "</span>";
    longCite = longCite + "<span style='font-variant:small-caps'>" + fullTitle + "</span>";
    pin1 = longCite;
    pin2 = " (";
    if (txtPublisher.Text.Trim() != "") { pin2 = pin2 + txtPublisher.Text.Trim(); }
    pin2 = pin2 + ", " + fullDate + ")" + country + URL;
    longCite = pin1 + pin2;
}

The strings built in the code above is written to a childnode of an XML file (excerpts below)...

            XDocument xRef = new XDocument(
        new XDeclaration("1.0", "utf-8", "yes"),
            new XElement("ref",
                new XElement("id", txtID.Text),
                new XElement("type",
                    new XAttribute("id", ddlType.SelectedValue.ToString()),
                    ddlType.SelectedItem.Text),
                new XElement("author",
                    new XAttribute("alpha", txtAuthorAlpha.Text),
                    txtAuthor.Text),
                new XElement("title", txtTitle.Text),
                new XElement("titlePrefix", txtTitlePrefix.Text),
                new XElement("subtitle", txtSubtitle.Text),
                new XElement("subDivider", txtSubDivider.Text),
                new XElement("language",
                    new XAttribute("id", ddlLanguage.SelectedValue.ToString()),
                    new XAttribute("display", ddlLanguage.SelectedItem.Text),
                    fullLang),
                new XElement("country", 
                    new XAttribute("id", ddlCountry.SelectedValue.ToString()),
                    new XAttribute("name", ddlCountry.SelectedItem.ToString())
                    ),
                new XElement("countries", txtCountries.Text.Trim()),
                new XElement("publisher", txtPublisher.Text),
                new XElement("date",
                    new XAttribute("day", ddlDay.SelectedValue.ToString()),
                    new XAttribute("month", ddlMonth.SelectedValue.ToString()),
                    new XAttribute("year", txtYear.Text),
                    fullDate),
                new XElement("longURL", txtLongURL.Text),
                new XElement("shortURL", txtShortURL.Text),
                new XElement("pin1", pin1),
                new XElement("pin2", pin2),
                new XElement("shortCite", shortCite),
                new XElement("longCite", longCite),
                new XElement("notes", txtNotes.Text)
            )
        );
        xRef.Save(Server.MapPath("~/App_Data/references/" + txtID.Text + ".xml"));

This works perfectly when I build and test it in the development environment. When I attempt it on Azure, it does not work. The XML file is created properly, with all of the nodes filled in, except for the pin1, pin2, and longCite nodes that are built within the if-then statement.

I have republished the entire site. I have republished the specific webform and code behind. I have deleted the XML files and recreated them in the web form on the local server and then again on the Azure server. Two identical websites. Two different results. When running it on my local machine, I set breakpoints within the if-then statement and it hits the breakpoints. I viewed the web form while it runs on the Azure server to ensure that the proper item on the DropDownList is selected and spelled correctly

<select name="ctl00$MainContent$ddlType" id="MainContent_ddlType">
...
<option selected="selected" value="monograph">Monograph</option>

Any ideas? Is there a known Azure and/or Visual Studio bug that I should be working around?

I have a legacy asp.net application that has a layout view which uses numerous calls to @Html.RenderAction to inject fragments of HTML from other controllers / actions.

One of these action methods renders a shared navigation tab bar (dark green) as in the example below (all green shaded objects are in the layout). Another part of the page (also dark green) uses the exact same model as the navigation tab.

Layout with multiple parts of the page that rely on the same model data

So the problem is that these Action methods make identical back-end calls to render the page. The same model is used in the content area as well, so 3 identical back-end calls are made to render a view when only one should be necessary. The same can be said of all pages in the application.

So in the case of the navigation, I'd like to introduce an abstract base ViewModel and strongly type that to the Layout view. Then I can change the @Html.RenderAction to @Html.RenderPartial and inject the shared model.

Does that seem like a sensible approach? If the navigation partial view was specified on each view I could pass the data without having to strongly type the layout. Having said that, the data in question is common across the whole application so the layout makes sense.

I guess the issue is that I have always thought of the layout as being a container for common application 'chrome' which hasn't required a model to render it (e.g. footers, logos, title etc). Is there any reason why the strongly typing of the layout is wrong / to be avoided?

I got a asp.net web forms project from TFS and unable to find sln file or csproj file to open in visual studio. the project opens fine when i open it as website but i am getting build errors like

could not load file or assembly AjaxControlToolKit or its dependencies

and also

Unknown Server tag asp:ToolkitScriptManager

i think this is because it doesn't have the reference path.

but how can i open the solution and build it

I've followed this Github page and I've encouter problems with Bearer Token Authentication/Authorization in this class. In this class the file (photo) is being uploaded.

Overhere I've send a POST request to the server (running in Docker), which is deliverd. The server returns a 4XX error, because the authentication isn't working (yet).

See here (POST with phone in Android): enter image description here

In this part of code I try to add the Bearer Token:

 public void connectForMultipart() throws Exception {
    con = (HttpURLConnection) ( new URL(url)).openConnection();
    con.setRequestProperty("Authorization", "Bearer hereIsMyBearerToken.SomeTextAnd.SomeRandomNumbers132");
    con.setRequestMethod("POST");
    con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    con.setRequestProperty("Connection", "Keep-Alive");
    con.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
    con.setUseCaches(false);
    con.setDoInput(true);
    con.setDoOutput(true);
    con.connect();
    os = con.getOutputStream();
}

Following to multiple sources the part con.setRequestProperty("Authorization", "Bearer TOKENEHERE") should work.

In Postman it's working fine, so my token is right. See here (POST with Postman to test): enter image description here

Docker also sends 201 (OK) back: enter image description here

I've also tried to authorized in the UploadActivity on the Github linked above. Without success. See here what I've tried in the SendHttpRequestTask class in the UploadActivity:

private class SendHttpRequestTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {
        String url = params[0];
        //String param1 = params[1];
        //String param2 = params[2];
        Bitmap b = BitmapFactory.decodeResource(UploadActivity.this.getResources(), R.drawable.c10);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        b.compress(Bitmap.CompressFormat.PNG, 0, baos);

        try {
            HttpClient client = new HttpClient(url);
            client.connectForMultipart();
            //client.addFormPart("param1", param1);
            //client.addFormPart("param2", param2);
            client.addFilePart("photo", "logo.png", baos.toByteArray());
            client.addFormPart("Bearer hereIsMyBearerToken.SomeTextAnd.SomeRandomNumbers132");
            client.finishMultipart();
            String data = client.getResponse();
        }
        catch(Throwable t) {
            t.printStackTrace();
        }

        return null;
    }

So where and how should I authorize my POST request?

I am attempting to only add asp:gridviews that have been checked to my JQuery array. My issue with this is that all rows are added, regardless of check status.

What would be the proper way to only add checked rows to this array:

<script>
    $("#btnTest").click(function () {
        var AjaxData = {};
        var AjaxDataList = [];
        var grids = ["gridGreen", "GridRed""];
        var gridlen = grids.length;
        var i;
        for (i = 0; i < gridlen; i++) {
            $('[id*=' + grids[i] + ']').find('tr:has(td)').each(function () {
        var gridrow = $(this);
        var colno = 2;
            $('#checkboxtest input[type=checkbox]').each(function () {
                if ($(this).prop('checked')) {
                    AjaxData.fldPresenting = gridrow.find("td:nth-child(" + colno + ")").html();
                }
            }
        });
        AjaxDataList.push(AjaxData);
        Console.Log(AjaxDataList);
        }
    });
</script>

I have a program that I'm trying to get to work but running into some issues. I have a File Upload that when I hit it from a desktop it opens File Explorer. So since the Surface has Windows I'd expect it to do the same which it does, however is there a way that I can have it launch the built in camera instead? If I run the web program from any IOS device it opens the camera up or at least gives the option to. Anyone know if this is possible? I downloaded an app in the Windows Store that I saw on a forum but no luck didn't know if I could hard code something.

Found this which I can get it to ask to use camera.. but not sure how to tie that to the file upload http://blog.teamtreehouse.com/accessing-the-device-camera-with-getusermedia

I need help understanding the structure of a codebehind when I use a GridView and DetailsView with RowCommand buttons.

To start, on the HTML page I use bootstrap for the row and column then add an asp updatepanel and empty contenttemplate tag, after that all controls are added to the contenttemplate from the codebehind to allow reusability and not having to just "hide" controls when buttons are clicked.

The Page_Load event starts with creating, binding (in a separate method), and adding myGridView. myGridview has a buttonfield with a "Select" commandname and I attach a RowCommand event to handle the buttonfield.

The RowCommand event method empties the updatepanels contenttemplate then creates and adds myDetailsView. myDetailsView has 3 buttons (edit, delete, and close with appropriate commandnames) added to the footerrow (via adding controls to a panel then adding the panel to footerrow.cells[0])

Now I need help. with the given structure I just described then if I click one of the buttons on myDetailsView it does a postback which loads myGridView and I get an error about controls not matching up with the viewstate. So naturally the immediate route is to throw loading myGridView in "if (!IsPostBack)", but if I do that then I lose data to myGridView upon clicking its Select buttonfield and the RowCommand method never fires.

I'm using Skrill payment method in my asp.net web application.

When clicked on booking button it redirects to the Skrill for payments as:

protected void btnBook_Click(object sender, EventArgs e)
{
    // Mastercard   5438311234567890
    // Visa         4000001234567890
    // Amex         371234500012340

    string url = "https://pay.skrill.com/?";

    // Merchant Details
    url += "pay_to_email=" + "demoqco@sun-fish.com";
    url += "&recipient_description=" + "Banquet Halls Booking System";
    url += "&language=" + "EN";
    url += "&status_url=" + "";

    // Customer Details
    url += "&country=" + "Pakistan";

    // Payment Details
    url += "&amount=" + string.Format("{0:0.00}", (double.Parse(lblGrandTotal.Text) / 110.00));
    url += "&currency=" + "USD";
    url += "&amount2_description=" + Persons.Text + ":";
    url += "&amount2=" + lblPersons.Text;
    url += "&amount3_description=" + PerHeadRate.Text + ":";
    url += "&amount3=" + lblPerHeadRate.Text;
    url += "&amount4_description=" + Tax.Text + ":";
    url += "&amount4=" + lblTax.Text + "%";
    url += "&detail1_description=" + "Booking ID:";
    url += "&detail1_text=" + objDLBkg.SelectLastBkID();
    url += "&detail2_description=" + "Description:";
    url += "&detail2_text=" + "View all bookings in your Account.";
    url += "&detail3_description=" + "Banquet Hall:";
    url += "&detail3_text=" + lblBqtName.Text;
    url += "&detail4_description=" + "Booking Date:";
    url += "&detail4_text=" + DateTime.Now.Date.ToString("MM/dd/yyyy");

    // Split Gateway
    url += "&payment_methods=" + "WLT,ACC";

    Response.Redirect(url);
}

And shows error on redirect to Skrill:

JBWEB000065: HTTP Status 400 -


JBWEB000309: type JBWEB000067: Status report
JBWEB000068: message
JBWEB000069: description JBWEB000120: The request sent by the client was syntactically incorrect.


JBoss Web/7.5.9.Final-redhat-1

How I can solve it? Where I'm wrong?

Thanks in advance!

I'm trying to create a boostrap-slider on my page using a vue backend built with TypeScript and ASP net core. I'm using the standard template for Vue.js with TypeScript in ASP.NET Core.

I've imported the boostrap-slider types with

npm install --save @types/bootstrap-slider

and when I try to

import { Slider } from 'bootstrap-slider';

I get the error

ERROR in [at-loader] ./ClientApp/components/mycomponent/mycomponent.ts:3:24 TS2306: File '~~redacted~~/node_modules/@types/bootstrap-slider/index.d.ts' is not a module.

I have a legacy asp.net application that has a layout view which uses numerous calls to @Html.RenderAction to inject fragments of HTML from other controllers / actions.

One of these action methods renders a shared navigation tab bar (dark green) as in the example below (all green shaded objects are in the layout). Another part of the page (also dark green) uses the exact same model as the navigation tab.

Layout with multiple parts of the page that rely on the same model data

So the problem is that these Action methods make identical back-end calls to render the page. The same model is used in the content area as well, so 3 identical back-end calls are made to render a view when only one should be necessary. The same can be said of all pages in the application.

So in the case of the navigation, I'd like to introduce an abstract base ViewModel and strongly type that to the Layout view. Then I can change the @Html.RenderAction to @Html.RenderPartial and inject the shared model.

Does that seem like a sensible approach? If the navigation partial view was specified on each view I could pass the data without having to strongly type the layout. Having said that, the data in question is common across the whole application so the layout makes sense.

I guess the issue is that I have always thought of the layout as being a container for common application 'chrome' which hasn't required a model to render it (e.g. footers, logos, title etc). Is there any reason why the strongly typing of the layout is wrong / to be avoided?

I am populating a List in the controller with a range or values from 0.00-38.00, then storing the List in ViewData and displaying the html select using the Select Tag Helper in the view.

The problem is the html generated is not correctly displaying the option with the selected attribute.

//  Rating
var list_rating = new List<SelectListItem>();
double riskval = 10.00 // this typical comes from database 
string riskfmt = riskval.ToString("0.00");

for (double curval = 0;curval < 38.25; curval += 0.25)
{
    list_rating .Add(new SelectListItem
    {
        Text = curval.ToString("0.00"),
        Value = curval.ToString("0.00")
    });
}
//not working
//list_rating .Where(x => x.Value == riskfmt).FirstOrDefault().Selected = true;

//also not working
list_rating .Where(x => x.Value.ToString() == riskfmt.ToString()).FirstOrDefault().Selected = true;

//store the list in ViewData 
ViewData["SELECT_RISK_RATING"] = list_risk_rating_items;

enter image description here

Everything works as expected, except the selected option, SelectListItem where Selected = true, is not displaying the html option as selected

<option value="10.00">10.00</option>

*Here is the razor code for the select tag that does not work:

<select asp-for="risk_rating" class="form-control" asp-items="ViewBag.SELECT_RISK_RATING"></select>

**In addition, here are some of my other select tags which ARE working correctly using the same binding mechanism. These select tags use a simple numeric value not the formatted double value which isn't working.

<select asp-for="industry_id" class="form-control" asp-items="ViewBag.SELECT_INDUSTRY"></select>
<select asp-for="service_id" class="form-control" asp-items="ViewBag.SELECT_SERVICE"></select>