I have three tables. Word -> WordForm -> SampleSentence. Each Word has different WordForms and then each form can have one or more SampleSentence

CREATE TABLE [dbo].[Word] (
    [WordId]       VARCHAR (20) NOT NULL,
    [CategoryId]   INT          DEFAULT ((1)) NOT NULL,
    [GroupId]      INT          DEFAULT ((1)) NOT NULL,
    PRIMARY KEY CLUSTERED ([WordId] ASC),
    CONSTRAINT [FK_WordWordCategory] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[WordCategory] ([WordCategoryId]),
    CONSTRAINT [FK_WordWordGroup] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[WordGroup] ([WordGroupId])
);

CREATE TABLE [dbo].[WordForm] (
    [WordFormId]   VARCHAR (20)  NOT NULL,
    [WordId]       VARCHAR (20)  NOT NULL,
    [Primary]      BIT           DEFAULT ((0)) NOT NULL,
    [PosId]        INT           NOT NULL,
    [Definition]   VARCHAR (MAX) NULL,
    PRIMARY KEY CLUSTERED ([WordFormId] ASC),
    CONSTRAINT [FK_WordFormPos] FOREIGN KEY ([PosId]) REFERENCES [dbo].[Pos] ([PosId]),
    CONSTRAINT [FK_WordFormWord] FOREIGN KEY ([WordId]) REFERENCES [dbo].[Word] ([WordId])
);


CREATE TABLE [dbo].[SampleSentence] (
    [SampleSentenceId] INT           IDENTITY (1, 1) NOT NULL,
    [WordFormId]       VARCHAR (20)  NOT NULL,
    [Text]             VARCHAR (MAX) NOT NULL,
    CONSTRAINT [PK_SampleSentence] PRIMARY KEY CLUSTERED ([SampleSentenceId] ASC),
    CONSTRAINT [FK_SampleSentenceWordForm] FOREIGN KEY ([WordFormId]) REFERENCES [dbo].[WordForm] ([WordFormId])
);

I am taking the data from these tables to a front-end client and this then modifies the data and adds or deletes WordForms and SampleSentences.

I then bring the data back to the server.

Is there some way that Entity Framework can check to see changes in the object that I bring back to the server and make changes to the database or do I have to do some form of comparison where I check the before and after of the Word, WordForm and Sample Sentence objects?

For reference here are the C# objects I'm using:

public class Word
    {
        public string WordId { get; set; } // WordId (Primary key) (length: 20)
        public int CategoryId { get; set; } // CategoryId
        public int GroupId { get; set; } // GroupId

        // Reverse navigation
        public virtual System.Collections.Generic.ICollection<WordForm> WordForms { get; set; } // WordForm.FK_WordFormWord

        // Foreign keys
        public virtual WordCategory WordCategory { get; set; } // FK_WordWordCategory
        public virtual WordGroup WordGroup { get; set; } // FK_WordWordGroup

        public Word()
        {
            CategoryId = 1;
            GroupId = 1;
            WordForms = new System.Collections.Generic.List<WordForm>();
        }
    }

public class WordForm
    {
        public string WordFormId { get; set; } // WordFormId (Primary key) (length: 20)
        public string WordId { get; set; } // WordId (length: 20)
        public bool Primary { get; set; } // Primary
        public int PosId { get; set; } // PosId
        public string Definition { get; set; } // Definition

        // Reverse navigation
        public virtual System.Collections.Generic.ICollection<SampleSentence> SampleSentences { get; set; } // SampleSentence.FK_SampleSentenceWordForm

        // Foreign keys
        public virtual Pos Pos { get; set; } // FK_WordFormPos
        public virtual Word Word { get; set; } // FK_WordFormWord

        public WordForm()
        {
            Primary = false;
            SampleSentences = new System.Collections.Generic.List<SampleSentence>();
        }
    }

public class SampleSentence : AuditableTable
    {
        public int SampleSentenceId { get; set; } // SampleSentenceId (Primary key)
        public string WordFormId { get; set; } // WordFormId (length: 20)
        public string Text { get; set; } // Text

        // Foreign keys
        public virtual WordForm WordForm { get; set; } // FK_SampleSentenceWordForm
    }

I have implemented the EditGridView functionality exactly according to the example shown in the documentation here

However, the edit button does a postback with a URL that is very long, so long that it causes the HTTP Error 404.15, substatus defined here.

There is a work around, which is basically to increase the request limit as noted here

My question, why is the EditGridView postback URLs so long and is there a way to NOT have to resort to increase the request limit?

These are my codes, please help me... i really need some help me..

namespace MSLFTPGATE {

public class MSL_FTP_MainGate
{

    private string host = null;
    private string user = null;
    private string pass = null;
    private FtpWebRequest ftpRequest = null;
    private FtpWebResponse ftpResponse = null;
    private Stream ftpStream = null;

    public string DownloadFile(string FilePath, string FTPPath, string FTPUID, string FTPPWD, int bufferSize)
    {

        try
        {
            string filename = Path.GetFileName(FilePath);
            string FTPFullPath = FTPPath;

            FileStream file = File.Create(FilePath);
            FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(FTPFullPath + filename);
            ftp.Method = WebRequestMethods.Ftp.DownloadFile;
            ftp.Credentials = new NetworkCredential(FTPUID, FTPPWD);

            FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();

            Stream responseStream = response.GetResponseStream();

            long cl = response.ContentLength;
            int readcount;
            byte[] buffer = new byte[bufferSize];

            readcount = responseStream.Read(buffer, 0, bufferSize);

            while (readcount > 0)
            {
                file.Write(buffer, 0, readcount);
                readcount = responseStream.Read(buffer, 0, bufferSize);
            }

            responseStream.Close();
            file.Close();
            response.Close();

            return "Success";
        }
        catch (Exception ex)
        {
            return "ERROR:"+ex.ToString();
        }

    }

}

}

These are my codes, please help me... i really need some help me.. I need to DL a file from a different FTP,location or shared network

This question already has an answer here:

In ASP.NET MVC 5 I could use @Html.Action within a view to call a controller and render some ViewResult from the Controller Action within a View.

<li>
    @Html.Action("ProjectNameList", "ProjectView", new { area = "Projects" })
</li>

In ASP.NET Core MVC 6, @Html.Action is not available now. I cannot find anything in the ASP.NET Docs. Cannot find much from my trusty dev companion Google either.

Has this been removed or is it hidden away in additional dependencies I need to download? Or is there a better way of doing this with MVC?

I have other places I use this approach in an MVC 5 project and one of them is using a Controller soley responsible for getting the current user that is displayed in the main view - not for the current routed controller for a url.

I have created a library project.

I have added antaris razor nuget to this library project.

I created a test.cshtml file:

@model RZTest.User
<div>Name: </div>@Model.Name

I have put a breakpoint on the line with the '@Model.Name' so the debugger should stop there.

But it did not stop!

var config = new TemplateServiceConfiguration();
config.Debug = true;

using (var service = RazorEngineService.Create(config))
{
    var template = File.ReadAllText("./test.cshtml");
    var user = new User { Name = "Horst" };
    string result = service.RunCompile(template, "key", null, user);
}

UPDATE

My 2nd approach was code:

  static void Main(string[] args)
        {
            string templateFile = "./test.cshtml";
            string htmlString = File.ReadAllText(templateFile);

            var template = new LoadedTemplateSource(htmlString, templateFile);
            Engine.Razor.Run(template.Template, typeof(User), new User { Name = "Test" }, null);

}

But then I get the error message that the key was not found. And the key was the content of the cshtml file...???

UPDATE 2

  string templateFile = "./test.cshtml";
  string htmlString = File.ReadAllText(templateFile);
  var model = new User { Name = "Test" };

RazorEngine.Engine.Razor.RunCompile(htmlString, "templateKey", typeof(User), model);

This code runs but how can I debug the compiled html to check the output? RunCompile is a void method.

I have an asp.net mvc site and I'm unable to sort on a field that is calculated when needed in the model.

    private decimal _total = -1;
    public decimal Total
    {
        get
        {
            if (_total < 0)
            {
                _total = get_total(TableId);
            }
            return _total;
        }
    }

    private decimal get_total(int id)
    {
       ....Many Calcs
    }

I'm trying to sort on Total, but I get the error:

Additional information: The specified type member 'Total' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.

Here is my actionlink:

@Html.ActionLink("By Total", "Index", new { sortOrder = ViewBag.Total, currentFilter = ViewBag.CurrentFilter }, new { @class = "btn btn-danger" })

I have found some similar issues, but I just can't figure out what how to sort by this.

I have a RadListview where all the items are always in edit mode using an EditItemTemplate. I have a button outside the radlistview that should save the changes made on each of the items, the problem is that when I click the button all the data typed on the controls in the list view is lost on the postback so I always get empty values.

protected void Button1_Click(object sender, EventArgs e)
{        
    foreach (RadListViewEditableItem item in rlv_OI.EditItems)
    {
        System.Collections.Hashtable newValues = new System.Collections.Hashtable();
        item.ExtractValues(newValues);
        string id = item.GetDataKeyValue("id").ToString();

        RadTextBox rtbSO = (RadTextBox)item.FindControl("rtb_SO");

        string strT = rtbSO.Text;        
    }

}

Anyone have any idea wahy is this happening?, I suppose it is something related with the view sate.

As a note I need to always have the items in edit mode and save all items togehter.

Thanks

asp.net 4.5.512 has not been registered on the web server. You need to manually configure your Web server

Note: 1) I ran "aspnet_regiis -i" at "C:\Windows\Microsoft.NET\Framework\v4.0.30319", now I'm getting 6 message boxes with same above error message 2) I tried turing on "IIS-ASPNET45" in "Turn Windows Features On/Off" under "Internet Information Services-> World Wide Web Services -> Application Development Features -> ASP.NET 4.5".

I am creating an ASP.NET application using WebForms. However, I am getting the following error:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: The compiler failed with error code -1073741515.

I did not make any changes, but the template is not working.

i can open jquery dialogue from gridview Edit button,But the problem is i am noot able to get each window for each edit button click.Can we open dialogue windows for each edit button.As of now what i did is in gridview row command event i am calling jquery function as shwon below.But each edit button it will open only the window responsible for that edit button.But i need each window for each edit click , how to do that?

here is my code

in gridview row command

called like \

 ScriptManager.RegisterStartupScript((sender as Control), this.GetType(), "alert", "showDetails('idsMain','ID DETAILS','1100','400');", true);

and this is the jquery used

function showBscDetails(divobj, pagetitle, width, height) {
    $("#" + divobj)
          .dialog({
              open: function () {
                  $(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar").addClass("ui-state-error");
              },
              title: pagetitle,
              appendTo: "form",
              modal: false,
              draggable: true,
              resizable: true,
              position:[180,10],
              width: width
          })

We are presenting the files created using different ways to user in web application using below mentioned code but recently (since last week) all files started to have HEX character at the beginning and 0 in the end line; see image. This makes the files invalid. If we save the file and remove first and last line the files become good. Also the issue is not with the file creation; its only when its presented to the user. If we go to the temporary app folder where we create files on web server the files are good. Only the response is creating some issue.

Any idea what could have triggered this thing. How can we fix this.

[Screenshot showing Invalid export data][enter image description here]1

We tried uninstalling few recent windows updates but nothing changed.

Win Server: 2008 R2 Service Pack1

.Net Framework: 3.5

Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "attachment;filename=" + <string>);
Response.Flush();
Response.BinaryWrite(<byte[]>);
Response.BufferOutput = true;
Response.Flush();
Response.End();

Thanks

I am having some trouble figuring out how to call a method I wrote in the .CS file that will update the user password in the database.

Here is my current form:

 <form method="post" action="#" runat="server" name="edit_password_form">
    <div id="edit_password_popup">
        <table width="390" align="center" padding="10">
            <tr>
                <td><span class="error_field">*</span>Password:<br>
                    <input type="password" name="password_1" id="password_1" size="19" maxlength="30" autocapitalize="off" autocorrect="off" autocomplete="off">
                </td>
                <td><span class="error_field">*</span>Confirm Password:<br>
                    <input type="password" name="password_2" id="password_2" size="19" maxlength="30" autocapitalize="off" autocorrect="off" autocomplete="off">
                </td>
            </tr>

             <tr>
                <td><input type="submit" value="Add Password" id="add_pass" alt="Add Password" border="0"></td>
                <td><input type="button" value="No Thanks" id="no_thanks" alt="No Thanks" border="0"></td>
             </tr>
        </table>
    </div>
</form>

Should I maybe have the c# method in the .aspx file instead of the .aspx.cs?

I want the C# method to run when the add_pass button is clicked. Any ideas on how I can achieve that?

My project is using DNX SDK v1.0.0-rc1-update1

I have a simple model defined as follows

public class MyModel {
    public IEnumerable<string> MyStrings { get; set; }
}

and a simple view as follows

@model MyModel
@foreach (string msg in Model.MyStrings)
{
    <input type="text" asp-for="msg" value="@msg" />
}

however, I get a red squiggle in VS 2015 telling me the model MyModel has no property msg. What is the correct way to use the asp-for when the property is an enumerable within a for loop? I considered using IEnumerable<T>.ElementAt(index) but I'm not really sure. I would appreciate any links to guides or documentation on the asp-for syntax.

I am uploading 3 types of files, i.e 1)video 2)image 3)document. if i am uploading all three files at once so it is upload and show successfully, but if i want to skip one the file of uploading then it giving me following errors. Please Help me here: httpPostedFile.SaveAs(fileSavePath); db.SaveChanges(); one the errors is because of sending path to db i guess.

[HttpPost]
    public ActionResult AddSKU(SKU_Det skufiles, IEnumerable<HttpPostedFileBase> files)
    {
        var httpPostedFile = Request.Files[0];
        if (httpPostedFile != null)
        {
            var uploadFilesDir = System.Web.HttpContext.Current.Server.MapPath("~/Content/Videos");
            if (!Directory.Exists(uploadFilesDir))
            {
                Directory.CreateDirectory(uploadFilesDir);          
            }

            var fileSavePath = Path.Combine(uploadFilesDir, httpPostedFile.FileName);
            httpPostedFile.SaveAs(fileSavePath);
        }
            foreach (var file in files)
            {
                if (file != null && file.ContentLength > 0)
                {
                    file.SaveAs(HttpContext.Server.MapPath("~/Areas/Admin/Images/") + file.FileName);
                }
            }

            SKU_Det sku = new SKU_Det();

            sku.SKU = skufiles.SKU;
            sku.VideoPath = Request.Files[0].FileName;
            sku.Imagepath = sku.FilePath = Request.Files[1].FileName;
            sku.FilePath = sku.FilePath = Request.Files[2].FileName;
            db.SKU_Det.Add(sku);
            db.SaveChanges();

I currently am working with the following tag which is rendered as a button with only an icon on it.
I would like this to be the icon followed by the words Export PDF.

Normally, I would not go about creating the button like this but I am using a Kendo control which produce the button for me. Once rendered the button looks as follows:

<a href="" role="button" class="k-tool k-group-start k-group-end" 
    unselectable="on" title="Export PDF">
    <span unselectable="on" class="k-tool-icon k-pdf"></span>
    <span class="k-tool-text">Export PDF</span>
</a>

I am trying to use JQuery to inject my wanted text into the element as follows:

<script>
        $(document).ready(function () {
            $('.k-tool-icon').text("Export PDF");
        });
</script>

however this does not change anything. I still get the button with only an icon.

Edit: Below is the C# MVC kendo editor that is rendering the above posted html:

@(Html.Kendo().Editor()
      .Name("editor")
      .HtmlAttributes(new { style = "height:900px" })
      .Pdf(pdf => pdf
          .Margin(20, 20, 20, 20)
          .ProxyURL(Url.Action("Pdf_Export_Save", "Editor"))
      )
      .Tools(tools => tools
          .Clear()
          .Pdf()
      )
      .Value(@<text>
        <code>
            @Html.Raw(HttpUtility.HtmlDecode(Model.ReportString))
        </code>
    </text>)
    )

This is a really elementary question and I have searched for an answer but there seems to be none to be found. This is dealing with the Scaffolded MVC5 edit.cshtml using VS2015.

I have a 1:M relationship between 2 tables, and the child table has a @Html.DropDownList as a foreign key to the parent. I need to filter that @Html.DropDownList. These are the specifics:

One AssociationList has many AgsweepParameters.

The primary key of AssociationList is AssociationListId Therefore the AssociationListId field is the Foreign key in the AgsweepParameter table.

Using EntityFramework, and MVC5 Scaffolding, I created the crud views/controllers using Entity Framework as the model.

The generated declaration for that dropdown looks like this:

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

Question: How do I filter that dropdown list so that AssociationList.AssociationType=="ACA"?

Note that I use a similar filter on the Index.cshtml on AssociationList table which looks like this:

            @foreach (var item in Model.Where(row=>row.AssociationType=="ACA")) {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id=item.AssociationListId }) |
                        @Html.ActionLink("Delete", "Delete", new { id=item.AssociationListId })
                    </td>
                </tr>
            }

So I have four radio buttons that are bound to one of my model's properties all with different values. However, when the form submits, that property is returning null (while everything else returns correctly). Code:

<div id="RadioButtonGroup">
    <label asp-for="Object.PropertyOne" class="radio-inline">
         <input asp-for="Object.PropertyOne" value="A"  type="radio" name="optradio" >Option One
    </label>
    <label asp-for="Object.PropertyOne" class="radio-inline">
         <input asp-for="Object.PropertyOne" value="B"  type="radio" name="optradio" >Option Two
    </label>
    <label asp-for="Object.PropertyOne" class="radio-inline">
         <input asp-for="Object.PropertyOne" value="C"  type="radio" name="optradio" >Option Three
    </label>
     <label asp-for="Object.PropertyOne" class="radio-inline">
         <input asp-for="Object.PropertyOne" value="D"  type="radio" name="optradio" >Option Four
    </label>
</div>

I select one, submit the form, and Object.PropertyOne returns null. But if I manually set Object.PropertyOne in my ViewModel, it displays correctly. What am I missing?

How can I convert a dropdownlist into a textbox using a button's onclick event. The dropdownlist's value will be retrieved from a database. Please see below for my code snippets:

<script type="text/javascript">
$(document).ready(function () {
$("#id").change(function () {
    var pq = $("#id").val();
    var booksDiv = $("#booksDiv");
    $.ajax({
        cache: false,
        type: "GET",
        url: "@(Url.RouteUrl("DuabyPurposeId"))",
        data: { "id": pq },
    success: function (data) {
        var result = "";
        booksDiv.html('');
        $.each(data, function (Id, Dua) {
            result += '<b>Dua Name: </b>' + Dua.Dua_name + '<br/>' +
                        '<b> Arabic Word :</b>' + Dua.Arabic_word + '<br/>' +
                         '<b> Translation English:</b>' + Dua.Translation_English + '<br/>' +
                          '<b> References :</b>' + Dua.Source + '<hr/>';

        });
        booksDiv.html(result);
    },
    error: function (xhr, AJAXOptions, thrownError) {
        alert('Failed to retrieve Dua FromDatabase.');
    }
});
 });
});
</script>
<div>
@Html.LabelFor(model => model.id)
@*@Html.TextAreaFor(model => model.id,Model.PurposeList)*@
@Html.DropDownListFor(model => model.id, Model.PurposeList, "Please Select         any relative  ")
</div>
<div id="booksDiv"></div>

I have an MVC 5 project I'm working on. I am seeing some unexpected behavior when using the Html.DisplayFor method.

There is an existing page that uses Html.DisplayFor with a particular model. I need to use Html.DisplayFor on a different page, but with the same model. When I try to do this, I get unexpected behavior. It does not render the same thing even though the model is the same.

It seems safe to assume that the system is not using the same view because when I modify the view, the resulting page does not change. I've concluded that it's using the wrong view.

How do I tell what view is being used to render when I use Html.DisplayFor?

I'm trying to update my query from MVC Client, after i update an item. In my attactched image, i show this staps: 1. Start with the meanning Web 2. Show the database and the only item. 3. Insert an item to the data. 4. Show the refresh data on Database. 5. Refresh the query on Web, but doesn't happen. 6. I Restart my ASMX Service, and then, i view the query result.

Maybe is concept problema or something to configure on Web Service. My Web client (MVC) manages the Session State on ASP.NET State Service.

ANIMATED PRINT SCREEN: link

I'm using .Net 2015, jQuery, Ajax, Fluent Nhibernate, ASMX, MVC Razor and Sql Server Database. Thanks.

I've been asked to migrate a web application from Server 2003 (IIS 6.0) to Server 2012 R2 (IIS 8.5).

I have some old source code but I'm not sure whether it matches what's currently deployed, so I'm trying to just move the deployed files from one server to another.

It kind of works, but there's an issue with trailing slashes and default documents I could use some help with.

It's a .NET 4.0 web forms application, forms authentication, but with some MVC thrown in for good measure!

On the current server, Fiddler reveals the following behaviour

However, on the new server, it's different

I'm at loss to work out how to fix things on the new server. I'm reluctant to change code and re-deploy as this will open a whole new can of worms I'm sure.

Help appreciated. Thanks.

Doug