I have MVC view page where i have text area and input box and javascript function assigned to button like this

function Process() {
    var input = $("#PrologUserInputTextArea").val();
    var query = $("#PrologQueryTextArea").val();

    $.get("@Url.Action("Process")", { userInput: input, query: query }, function (data) {
        cleanDiv();
        $("#PrologResultTextArea").val(data);
        //do some work with 
    });
}

and in mvc controller i have method just like this :

public async Task<string> Process(string userInput, string query)
{
    try
    {
        return await Proc.Process(userInput, query);
    }
    catch (PrologException e)
    {
        return e.Message;
    }
}

This works as it should when I write small amount of text in text area (about 50 lines) but when I try several hundreds of lines this wont pass the string to controller. Is there some check in javascript where this function won't pass the string? How can I pass enormous string to controller?

I'm trying to add a transparent watermark to a series of images using System.Web.Helpers.WebImage.AddImageWatermark, the original image is a .jpg.

I've tried both .gif and .png with transparency but WebImage seems to ignore transparency and treat the transparent background as black. The higher the opacity passed into AddImageWatermark the darker the black. Is there any way to do this using WebImage?

Is it possible to add content of txt file to Viewbag being inside the Controller? How to do it?

I have a simple login screen which uses ajax to login to the system, the css and scripts are all loaded using bundles.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="target-densitydpi=device-dpi; width=device-width;initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/css")   

</head>
<body>

@RenderBody()
@Scripts.Render("~/bundles/jquery")
</body>
</html>

All of my scripts work perfectly on page load, but once i have logged in and click on the logout button, i get redirected to the login screen but none of my scripts no longer work. i think this is because of the way i am redirecting the user once they have clicked on the logout button, looking at the URL it still says that im on the ~/Home/Logout instead of the ~/login/index.

here is the code im using to logout my users.

@{
ViewBag.Title = "Home";
}

<div data-role="page">
    <div>
        <div data-role="navbar">
            <ul>
                <li>@Html.ActionLink("Logout", "Logout",  "Home"  , null, null)</li>
                <li><a href="#" id="btnFilter">Filter</a></li>
            </ul>

            <div id="filter" style="background-color:#F6F6F6;">
                <div style="padding: 0px 5px;">
                    <select id="ddlAudits">
                        <option value="-1">Select Inspection</option>
                        @foreach (var i in ViewBag.AuditDropDown)
                        {
                            <option value="@i.AuditID" >@i.AuditTitle</option>
                        }
                    </select>

                    <select id="ddlAccounts">
                        <option value="-1">Select Account</option>
                        @foreach (var i in ViewBag.AccountDropDown)
                        {
                            <option value="@i.AccountID" >@i.AccountName</option>
                        }
                    </select>
                </div>
            </div>
        </div>

        <div id="DivAccounts">
        </div>

</div>

I have tried setting the logout button on my home page to

<a href="~/">Logout</a>

but the scripts still fail to load once i am redirected back to the login screen. im having a little difficulty understanding this as ive only been doing MVC for a little over a month.

and here is my action which is being called with ajax to logout the users

public ActionResult Logout()
    {
        FormsAuthentication.SetAuthCookie("ctUserID", false);
        FormsAuthentication.SignOut();
        return Redirect("~/");
    }

Any help / advice will be greatly appreciated.

I have a requirement to create a directory on my applications server which is secure to all, but the application itself.

I have read this article

System.IO.Directory.CreateDirectory with permissions for only this current user?

Converting to VB, the code it suggests is:

Dim ds As New DirectorySecurity()
Dim sid As New SecurityIdentifier(WellKnownSidType.CreatorOwnerSid, Nothing)
Dim ace As New FileSystemAccessRule(sid,
        FileSystemRights.FullControl,
        AccessControlType.Allow)
ds.AddAccessRule(ace)

Directory.CreateDirectory(Dir, ds)

But when I follow that code instruction there, I cannot add files to the directory I have created.

I am guessing I should change the value of WellKnownSidType but I do not know what to!

To recap - what I need is a directory which my application can read and write to, but a user cannot access from a web browser to download any content.

Any help much appreciated!

How can I set an Entity Data Source connection string from a variable set in the codebehind page.

e.g. something like this in the code behind

string edsconstring = "name=EDSEntities";

and then in the aspx

        <asp:EntityDataSource ID="UnAuthPricesEDS" runat="server" 
            ConnectionString=<%= this.edsconstring %> DefaultContainerName="CS3Entities" 
            EnableFlattening="False" EntitySetName="CustomersItems" Where="it.Authorised=false"
            OrderBy="it.DateSet" >
    </asp:EntityDataSource>

Earlier i was using SQL-Server(relational Database) in my project,but now i want to sift into Non-relational Database(Azure Table).

i know the basic of Advantages of Non-Relational database and Azure table also Primary-Key,Row-key,it's uses and importance. i Know How to create table in azure table,retrieve data from that,Insert update and delete.

felling lot of confusion when i am going to design table in Non-Relational database.

suppose i have a table structure like this in my relational databaseenter image description here

then what will it's possible table design in azure table?

provide some useful links where i can get different design strategy in azure table with some example.

I am developing an application in which their exist a problem. When i click on to submit button, the data is inserted into db. But when i press ctrl+R or f5 a chrome or IE pop up occurs which says Confirm Form Resubmission. when i click continue then the record is duplicated into database.

My question is,

  1. Why is this popup occuring? because of the postback? if because of postback then do my code have any issues or it occurs with every body when doing postback.

  2. Will using mvc will solve this issue completely?

My code:

protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                paramArray = new string[9];
                paramValues = new object[9];
                try
                {
                    paramArray[0] = "@AccountNumber";
                    paramValues[0] = (!string.IsNullOrEmpty(this.txtAccountNumber.Value) ? this.txtAccountNumber.Value.Trim() : string.Empty);

                    paramArray[1] = "@OpeningBalance";
                    paramValues[1] = (!string.IsNullOrEmpty(this.txtOpeningBalance.Value) ? Convert.ToDouble(this.txtOpeningBalance.Value.Trim()) : 0.00);

                    paramArray[2] = "@ClosingBalance";
                    paramValues[2] = (!string.IsNullOrEmpty(this.txtClosingBalance.Value) ? Convert.ToDouble(this.txtClosingBalance.Value.Trim()) : 0.00);

                    paramArray[3] = "@PaymentMode";
                    paramValues[3] = this.ddlModeofPayment.Value;

                    paramArray[4] = "@PaymentDate";
                    paramValues[4] = this.dtPaymentDate.Value;

                    paramArray[5] = "@PaymentAmount";
                    paramValues[5] = (!string.IsNullOrEmpty(this.txtPaymentAmount.Value) ? Convert.ToDouble(this.txtPaymentAmount.Value.Trim()) : 0.00);

                    paramArray[6] = "@isAccount";
                    paramValues[6] = true;

                    paramArray[7] = "@UserId";
                    paramValues[7] = (!string.IsNullOrEmpty(this.User.Identity.Name.Remove(0, 7)) ? this.User.Identity.Name.Remove(0, 7) : string.Empty);

                    paramArray[8] = "@isProcessed";
                    paramValues[8] = default(bool);

                    var success = herlperUtility.ExecuteParameterizedQuery("{CALL asp_sp_InsertPayment(?,?,?,?,?,?,?,?,?)}", paramArray, paramValues);

                    if (!string.IsNullOrEmpty(success.Rows[0]["ReferenceNumber"].ToString()))
                    {
                        this.Page.Response.Redirect("AccountPaymentScreen.aspx?flag=1");
                        divSuccess.Attributes.Add("style", "display:block");
                        this.refId.InnerText = "<b>Success!</b> The " + success.Rows[0]["ReferenceNumber"] + " has been successfuly forwarded to the supervisor";

                        this.ClearFields();
                    }

                    else
                    {
                        this.divFailure.Attributes.Add("style", "display:block");
                    }
                }
                catch (Exception ex)
                {
                    this.divFailure.Attributes.Add("style", "display:block");
                    this.divFailure.InnerText = ex.Message;
                }
            }

I have some code bellow :

Protected Sub Page_Load(....
 If Not IsPostBack Then 
   Session("isloaded") = True
   PopulateData()
 End If
 If Session("isloaded") = True Then Session("isloaded") = False Else PopulateData()
End Sub

Private Sub btnEditCancel_Click(....
 Session("isloaded") = False
End Sub

Private Sub btnEditSave_Click(...
 Session("isloaded") = True
 PopulateData()
End Sub

Because, when I click btnEditSave Repeater is populated. But, when I click btnEditCancel Repeater isn't populated. PopulateData() is subroutine for populating asp:Repeater using asp:SqlDataSource. btw. EnableViewState in asp:Repeater is disabled.

How to solve this problem?

Is it possible that Page_Load fire first and after that Session("isloaded") is set to False?

p.s. sorry for my weak english, I hope you, people, will understand point of question.

How to change the order of Div when we send value from textbox, when we click on send button the textbox value goes into div but the order is top but if we want to change the order .... can is it...

<div id="msgtxttt" style="width:200px;background-color:silver;height:200px;"></div> 
</br> 
<input id="msgtxt" type="text" />
</br> 
<span id="searchbtn" style="cursor:pointer;" onclick="send();">Send</span>



 <script type="text/javascript"> 

function send(){ var txt = $.trim($('#msgtxt').val());
 var box = $("#msgtxttt").html();
 if(box!="")
  {
      $("#msgtxttt").html(box +"<br />" +txt);
  } 
  else
       $("#msgtxttt").html(txt);
       $('#msgtxt').val(""); 
  } 

</script>

i want to edit a picture and place some text form text box upon it e.g i type something in textbox and upon clicking save button it should appear on image and should be saved permanently with it like being pasted . Note: image could be any browsed and uploaded picture.

I have an Asp.Net page which has process payment. Admin can process the payment. There can be multiple admins. If a page is open in 2 browsers and admin clicks Process payment, double payment is charged to customer.

I could do a check in my button click handler / controller method that we should not charge payment if it has been already charged once. However, that too doesn't prevent the problem entirely because if both of them click process payment at the same time it could again lead to issue. How can I solve this problem?

Should I be using lock / mutex. Please suggest what is the best way to solve this such that customers don't suffer.

I have created a website in asp.net for a company. Now i required to upload this website into their intranet network. Please tell me the step by step process. Thank you in advance.

I have an Asp.net 4.0 solution that compiles properly on each local development machine using VS2010 but when I run a build on our build box it gives me this error

ASPNETCOMPILER: Could not load file or assembly 'MagickNet' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I have installed Imagemagik on the build box which has the VC++ runtime required, changed the build configuration to Mixed Platform, Any CPU; but still the error keeps coming. The buildbox doesn't have any visual studio installation. Its a win2012 R2 server with .Net 4.0 framework installed. What could be the problem?

Is there a way to detect hotlink image views in ASP.NET / IIS 7 ? I don't want to block the viewers, I just need to increment the image views counter for each static image when someone clicks on my images in google image search.

I am working on a project with MVC 4 and Entity Framework.

I have created the entity model with autogenerated classes from database. But, I want different names and methods for classes in the Models.

For instance, it has been generated this class:

 public partial class tbl_Templates
    {
        public tbl_Templates()
        {
            this.tbl_Template_Sections = new HashSet<tbl_Template_Sections>();
        }

         public int TemplateId { get; set; }

         //...
    }

But i dont want to use this class, so I have created my own class in the modeler:

public class Template : tbl_Templates
{
    public Template()
        : base()
    {

    }

    // I'll add custom methods later
}

Now, how can I use this one in the controller?

I tried:

  List<Template> Templates =db.tbl_Templates.Cast<Template>().ToList();

but i get the exception:

LINQ to Entities only supports casting EDM primitive or enumeration types.

I have a huge web application in asp.net which is developed for US client.

  1. Now I want to use the same application for UK client, but the problem here is the date format for us will be MM/dd/yyyy format where as in uk it will be dd/MM/yyyy.
  2. Likewise the label will differ from country to country, for example in us client will refer as "Check" but the same in uk will be "cheque"

How can i overcome from these compatibility issues.

And these labels which has inline value that need to change without altering any codes.

I saw something about resource file which does this,but I dont know how to implement this for different regions date,Currency format.Or how to do the date conversion using these resources...?Or do we have any other format do these..?

Please can anyone suggest me the way to do this..

Sorry if this seems simple. Either I'm not asking the right question, or understanding the answers I've found so far.

i need to join columns (Ex. tbl_lockers has Employee and tbl_employee has Name column)

I need to join the same data from tbl_employee.Name to tbl_lockers.Employee Any thoughts? Thanks.

im a newbie in sql.

So I am creating a link in my webpage named uploadedFiles.cshtml using the following code:

 <a href="@Model.doc1" download="doc_submit1" target="_blank" name="download"/>

Here the path of the file to be downloaded is fetched from the model passed from the controller

as you see the @Model.doc1 contains the file's address

Now I created a test webpage in .html with the same anchor tag and that allows me to download the file. And I'm confused!

The problem being that the link in .cshtml file doesn't start a download whereas the same code in .html file downloads the specified file.

I have a view which contains a partial view that contains a form and rendered when a button is clicked and is displayed in a popup on the view. The issue is when i click the submit button the form saves but it then redirects me to action's view which i don't want to happen. I want to be able to click the submit button and form to post but not return anything...keeping the view looking the same as before (appearing that nothing has happened)". Is there anyway to do this?

Here is my Partial View:

@model EmployeeMaster.Models.EmployeeAsset


<h3><u>Does this employee have any of the following assets?</u></h3>

@using (Html.BeginForm("EmployeeAssets","Employee",FormMethod.Post, new {@id = "assets-form"}))
{
    @Html.HiddenFor(model => model.EmpNo)
    @Html.HiddenFor(model => model.ID)
    @Html.HiddenFor(model => model.UserName)
    @Html.AntiForgeryToken()
    <table class="table table-striped table-bordered table-condensed" style="margin-bottom: 0px;">
        <thead>
            <tr>
                <th>Item</th>
                <th>Yes/No</th>
                <th>Item</th>
                <th>Yes/No</th>
                <th>Item</th>
                <th>Yes/No</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    @Html.Label("Cellular Telephone")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.CellPhone, new {@class = "checkbox"})
                </td>
                <td>
                    @Html.Label("Mileage Log")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.MileageLog, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Travel Expense Reports")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.TravelExpenseReports, new { @class = "checkbox" })
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Computer")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Computer, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Pager")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Pager, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Uniforms")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Uniforms, new { @class = "checkbox" })
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Customer Database")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.CustomerDatabase, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Phone Card")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.PhoneCard, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Vehicle")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Vehicle, new { @class = "checkbox" })
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Gas Card")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.GasCard, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Security Card")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.SecurityCard, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Co Credit Card")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.CoCreditCard, new { @class = "checkbox" })
                </td>
            </tr>
            <tr>
                <td>
                    @Html.Label("Keys")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Keys, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Tools")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.Tools, new { @class = "checkbox" })
                </td>
                <td>
                    @Html.Label("Other PPG Property")
                </td>
                <td>
                    @Html.CheckBoxFor(model => model.OtherPPGProperty, new { @class = "checkbox" })
                </td>
            </tr>
        </tbody>
    </table>
    <input type="submit" value="save"/>
}

Here are my actions:

    public ActionResult EmployeeAssets(int empNo)
    {
        var assets =  _employeeDb.EmployeeAssets.FirstOrDefault(e => e.EmpNo == empNo);
        if (assets == null)
        {
            var newasset = new EmployeeAsset()
            {
                EmpNo = empNo
            };
            _employeeDb.EmployeeAssets.Add(newasset);
            _employeeDb.SaveChanges();
            assets = newasset;
        }
        return PartialView(assets);
    }
    [HttpPost]
    public ActionResult EmployeeAssets(EmployeeAsset asset)
    {

        _employeeDb.Entry(asset).State = EntityState.Modified;
        _employeeDb.SaveChanges();
        return null;
    }

Here is my Jquery for getting the form:

 $.ajax({
                type: 'GET',
                url: '@Url.Action("EmployeeAssets", "Employee", new { empNo = Model.EmployeeNumber })',
                success: function (data) {
                    $('#assets-container').html(data);
                }
            });
            $("#assets-button").on("click", function () {
                $('#assets-container').bPopup(
                {
                    modal: true,
                    appendTo: '#employee-edit-form',
                    onClose: function () {
                        alert('Form is submitting');
                        $('#assets-form').submit();
                    }
                });
            });

Before posting:

enter image description here

After posting:

enter image description here

I've been trying to get DataTable to work with my MVC 5 project, but I've had no luck. No CSS is showing on the headers of the columns to even show a hint of DataTable working. I've been working on this for about two days now with no success. Any help is appreciated, thanks!

@model IEnumerable<BlahBlahBlah.Models.tbl_Reg_User>

@{
ViewBag.Title = "Index";
}
@section Scripts{
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="~/Content/DataTables-1.10.3/css/jquery.dataTables.css">
<!-- jQuery -->
<script type="text/javascript" charset="utf8" src="~/Scripts/DataTables-1.10.3/js/jquery.js"></script>
<!-- DataTables -->
<script type="text/javascript" charset="utf8" src="~/Scripts/DataTables-1.10.3/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#thetable').DataTable();
    });
</script>
}

<body>
<h2>User List</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("CheckBoxAction", "User"))
{
    <input type="submit" name="deactivateButton" value="Deactivate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
    <input type="submit" name="activateButton" value="Activate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
    <table id="thetable" class="table">
        <thead>
            <tr>
                <th>
                    Select Users
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.ID)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.department)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.FirstName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.LastName)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Email)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.UserName)
                </th>

                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {

                <tr>
                    <td>
                        <input type="checkbox" name="ids" id="ids" value="@item.ID" />
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ID)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.department)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.FirstName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.LastName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Email)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.UserName)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
                        @Html.ActionLink("Details", "Details", new { id = item.ID }) |
                        @if (item.suspended)
                        {
                            @Html.ActionLink("Activate", "Activate", new { id = item.ID })
                        }
                        else
                        {
                            @Html.ActionLink("Deactivate", "Deactivate", new { id = item.ID })
                        }
                    </td>
                </tr>

            }
        </tbody>
    </table>
    <br />
    <input type="submit" name="deactivateButton" value="Deactivate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
    <input type="submit" name="activateButton" value="Activate Selected Users" onclick="location.href'@Url.Action("CheckBoxAction", "User")'" />
}

@*<input type="button" value="Deactivate" onclick="location.href'@Url.Action("CheckBoxDeactivate", "User")'" />
    <input type="button" value="Activate" onclick="location.href'@Url.Action("CheckBoxActivate", "User")'" />*@