I execute a stored procedure which returns results from a dynamic pivot. Since its a dynamic pivot I am unable to estimate what the value of the result headers. My query is being returned fine, I am not sure as to the mapping of this header column(s) a property in my object which is then send to excel. I need to render my SQL result in the following format to excel:

In the following TSBNumber is a property, SYstemXY is a VALUE of property Called SystemFullName for which the value is diplayed in the header and the datetime? is a property called CLosedDate

Sample Data Returned from SQL:

**TSBNumber**   SystemXY   SystemBB   SystemTT
asdas          1/1/2013    
1231                      1/1/2014
12312          1/1/2013
ASAWS                     1/1/2013
awsdS                               1/1/2013

Executing the stored procedure

return db.Database.SqlQuery<ServiceTsbExportDataRow>("[dbo].[spExportServiceTSB] @parm1, @parm2, @parm3, @parm4, @parm5",
                    new SqlParameter("parm1", StartDate),
                    new SqlParameter("parm2", EndDate),
                    new SqlParameter("parm3", UserRoleID),
                    new SqlParameter("parm4", SelectedSystemIDs),
                    new SqlParameter("parm5", SelectedTsbIDs)
                    ).ToList().ToHTMLTable();

Entity mapping the properties ServiceTsbExportDataRow

public class ServiceTsbExportDataRow
    {
        //This property gets displayd fine since i know the mapping
        public string  TSBNumber { get; set; }

        //Now How do I display my SystemFullName property? string array?

    }

TOHTML Table METHOD

public static string ToHTMLTable<T>(this IList<T> data)
        {
            PropertyDescriptorCollection props =
                TypeDescriptor.GetProperties(typeof(T));

            StringBuilder builder = new StringBuilder();

            builder.Append("<table border=\"1\">");

            builder.Append("<tr>");

            for (int i = 0; i < props.Count; i++)
            {
                builder.Append("<td>");

                PropertyDescriptor prop = props[i];

                builder.Append(prop.Name);

                builder.Append("</td>");
            }
            builder.Append("</tr>");

            object[] values = new object[props.Count];
            foreach (T item in data)
            {
                builder.Append("<tr>");

                for (int i = 0; i < values.Length; i++)
                {
                    builder.Append("<td>");

                    builder.Append(props[i].GetValue(item));

                    builder.Append("</td>");
                }

                builder.Append("</tr>");

            }

            builder.Append("</table>");
            return "<html><body>" + builder.ToString() + "</body></html";
        }

Finally Sending to excel

ExcelHelpers.ExportToExcel(context.HttpContext, typeName, htmlTable);

I have the following code placed at a button click. Button got clicked after user selects an image to upload.

using (SD.Image OriginalImage = SD.Image.FromStream(AsyncUpload.FileContent))
        {
            decimal dRatio = (Decimal)1024 / OriginalImage.Width;
            int iScaledW = 1024;
            int iScaledH = (int)(OriginalImage.Height * dRatio);
            using (SD.Bitmap bmp = new SD.Bitmap(iScaledW, iScaledH))
            {
                bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
                using (SD.Graphics Graphic = SD.Graphics.FromImage(bmp))
                {
                    Graphic.SmoothingMode =SD2.SmoothingMode.AntiAlias;
                    Graphic.InterpolationMode = SD2.InterpolationMode.HighQualityBicubic;
                    Graphic.PixelOffsetMode = SD2.PixelOffsetMode.HighQuality;
                    Graphic.FillRectangle(SD.Brushes.White, 0, 0, iScaledW, iScaledH);
                    Graphic.DrawImage(OriginalImage, 0, 0, iScaledW, iScaledH);
                    bmp.Save(Path.Combine(Server.MapPath(upPath), AsyncUpload.FileName));
                }
            }
        }

Here AsyncUpload is the name of FileUpload control. Original image is 3.96MB and by re-sizing the image with the above function, creates a re-sized image of 1.92MB.

However, If I select that same 3.96MB file as click a button that executes the following code that simply uploads whatever provided.

objfile.SaveAs(Path.Combine(Server.MapPath(upPath), AsyncUpload.FileName));

And then click a button that do the same processing of re-sizing the image as above mentioned, it creates an image of 200KB only. Below is the code of that button click.

static byte[] Crop(string Img, int Width, int Height, int X, int Y)
    {
        int w = Width;
        int h = Height;
        int xx = X;
        int yy = Y;

        try
        {
            using (SD.Image OriginalImage = SD.Image.FromFile(Img))
            {
                if (w == 0 || h == 0)
                {
                    w = OriginalImage.Width;
                    h = OriginalImage.Height;
                }

                int iScaleX = 0, iScaleY = 0;
                GetImageResolution(w, h, out iScaleX, out iScaleY);
                using (SD.Bitmap bmp = new SD.Bitmap(iScaleX, iScaleY))
                {
                    bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
                    using (SD.Graphics Graphic = SD.Graphics.FromImage(bmp))
                    {
                        Graphic.SmoothingMode = SmoothingMode.AntiAlias;
                        Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
                        Graphic.FillRectangle(SD.Brushes.White, 0, 0, iScaleX, iScaleY);
                        Graphic.DrawImage(OriginalImage, 0, 0, iScaleX, iScaleY);
                        bmp.Save(<Path>);
                    }

                }

            }

        }
        catch (Exception Ex)
        {
            return null;
            //  throw (Ex);
        }

    }

Both the code are same but the output images are of different sizes and that too, a big difference in size. Please help me understand why is this behavior. I want to avoid uploading big size image by reading them as stream and re-sizing them before even uploading them to disk. But the size after re-sizing is too big to accept.

Also, if anybody can share their thoughts of how to compress and image.

Thanks in advance

I am creating a page where users can edit database records for multiple fields in different rows. This method is required as users will be changing quite a few at a time and may need visibility of other objects displayed.

I'm currently having problems getting partial ViewModel data back into the controller to save to the database as razor seems to require me to have long names for model objects.

I am sending a list of viewmodels to the view. Each View model has a Customer specific model, and then a model for the Product Division (I need some of the information in here to display to the user). I am then using a foreach loop to cycle through each Division to create multiple forms on the page, which I will then be POSTing via Ajax to a controller.

The issue arrises that after I use the foreach loop I get longer input names which then do not feed back into the viewmodel on the controller side.

@foreach (var item in Model){
@Html.HiddenFor(model => item.PriceListDivision.DivisionID)
}

When this gets submitted back to the controller it doesn't match back to the view model as the input names are in this format item.PriceListDivision.DivisionID and I think it needs to be just PriceListDivision.DivisionID.

Is there a way to get around this or set the input names to just be PriceListDivision.DivisionID so that the controller correctly recognises the viewmodel. Or am I doing something very wrong.

Please let me know if viewing more code would be helpful - I have a feeling there is an easy way to overcome this though.

Is it just me or is it a step backwards to use @html.kendo() instead of html tags and @model.myfield razor syntax?

@html.kendo() takes control away from your output of html and in-lines javascript. Is this a good thing?

I am using the Kendo TabStrip control on my MVC view page. I have 4 tabs. I am using a partial view for each tab. I am using Ajax to render the HTML in each tab. I am also using jquery in my javascript in each of the partial views. Initially the tabs load fine, no issues. I have a submit button on each tab. When I click the submit button it does a postback to the server, does some work, returns to client and then switches to the next available tab. When it switches to the new tab, the old tab is returning an error:

microsoft jscript runtime error: object expected

I have been researching this issue and have not had any success in finding a resolution. I am helping you guys can help.

It's question around SOA architecture. At the moment, my company have desktop product with sql server and fox pro in the back-end. The product is deployed into clients so it's on-premise application.

My company develops cloud based MVC web app and there is requirement to extract lookup data from on-premise desktop app on client to display into cloud based MVC web app; so the data is client real time data.

I'm thinking for sql server synch service; but I see the cons is that it's applicable only for sql server. I'm looking for other possible alternatives. Is there any mechanism to convey on-premise information into cloud and it's application talking to other application pattern?

Thank you

Koronx.

Making a MVC5 project and published it to a local folder, FTP all file(include "App_Data" where it store user login to the server)

Website pull up data from MSSQL successfully, however when I click "Login" the page shoot out an error? Do I need to restore the mdf to server mysql and add an new mysql connection to the "defaultconnection" in Web.config?

enter image description here

So, I'm creating an application whose main purpose is to compute the area, perimeter, and inradius of a triangle. The user is supposed to enter three values that are of type double. & whichever button they click should spit out the answer in the result view. The user can click any button (it doesn't matter which). If they click the "area" button first & then decide to click the "perimeter" button, the result should change. Here is a picture to give you an idea of what it looks like: (http://tinypic.com/r/v3ncyh/8). I'm not sure if I am programming this correctly because my values look completely incorrect & I do not think my Views are connected correctly to my code. The first section of this code is my Triangle class that contains all my getters/setters & my methods for computing the area, perimeter, and inradius. The second section is my Activity which is the main (& only) Activity for my application.

public class Triangle {

// instance variables
private double sideA;
private double sideB;
private double sideC;

// Getters and setters
public double getSideA() {
    return sideA;
}

public void setSideA(double sideA) {
    this.sideA = sideA;
}

public double getSide2B() {
    return sideB;
}

public void setSideB(double sideB) {
    this.sideB = sideB;
}

public double getSideC() {
    return sideC;
}

public void setSideC(double sideC) {
    this.sideC = sideC;
}

// Constructor
public Triangle(double sideA, double sideB, double sideC) {
    this.sideA = sideA;
    this.sideB = sideB;
    this.sideC = sideC;
}

// Three methods...
public double getPerimeter() {

    return sideA + sideB + sideC;
}

public double getArea() {

    double s = 1/2 * (sideA + sideB + sideC);
    double area = Math.sqrt(s*(s-sideA)*(s-sideB)*(s-sideC));

    return area;
}

public double getInRadius() {

    double r = ((-sideA + sideB + sideC)*(sideA - sideB + sideC)*(sideA + sideB - sideC))/(4*(sideA + sideB + sideC));
    double answer = Math.sqrt(r);

    return r;
}

}

public class TriangleComputationActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_triangle_computation);

    // Declare our View variables and assign them the Views from the layout file
    final TextView lengthOne = (TextView) findViewById(R.id.lengthOne);
    final TextView lengthTwo = (TextView) findViewById(R.id.lengthTwo);
    final TextView lengthThree = (TextView) findViewById(R.id.lengthThree);
    final TextView result = (TextView) findViewById(R.id.result);

    Button areaButton = (Button) findViewById(R.id.area);
    Button perimeterButton = (Button) findViewById(R.id.perimeter);
    Button inradiusButton = (Button) findViewById(R.id.inradius);

    final Triangle triangle = new Triangle((double)lengthOne.getInputType(), (double)lengthTwo.getInputType(),(double)lengthThree.getInputType());

    // Methods in Action...
    areaButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            result.setText(triangle.getArea());

        }
    });

    perimeterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            result.setText(triangle.getPerimeter());
        }
    });

    inradiusButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            result.setText(triangle.getInRadius());
        }
    });

}

I have a table in my view with a column of Checkboxes. I want the user to be able to select as many Checkboxes as they'd like and click a button at the bottom to deactivate them (Users in this model can be suspended/deactivated and reinstated/activated). I don't have any errors, but nothing is happening when I click on the buttons. I attached my code below. Thanks.

View

@using (Html.BeginForm("CheckBoxDeactivate"))
{ 
<table class="table">
<tr>
    <th>
    Select Users
    </th>
    <th>
        @Html.DisplayNameFor(model => model.ID)
    </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>
        @Html.DisplayNameFor(model => model.suspended)
    </th>

    <th></th>
</tr>
@foreach (var item in Model) {
<tr>
    <td>
        <input type= "checkbox" name="manageUsers" value="@item.ID" />
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.ID)
    </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.DisplayFor(modelItem => item.suspended)
    </td>

</tr>
}
</table>
<br />
<input type="button" value="Add Roles" onclick="location.href'@Url.Action("CheckBoxDeactivate", "User")'" />



Controller

[HttpPost]
        public ActionResult CheckBoxDeactivate(int[] ids)
        {
        tbl_Reg_User OAWUser = new tbl_Reg_User();
        foreach (var id in ids)
        {
            OAWUser = db.tbl_Reg_User.Single(o => o.ID == id);
            OAWUser.suspended = true;
            db.SaveChanges();   
        }
ViewBag.Message = "Users deactivated successfully!";
        return View();
    }

I am looking into setting database routing up for a new website I plan to create. I have been looking at the following tutorial with regards to utilising friendlyUrls from a database:

http://www.asp.net/web-forms/tutorials/aspnet-45/getting-started-with-aspnet-45-web-forms/url-routing

However, I would like to use the same route structure for multiple entities. Meaning:

mysite.com/{PlayerName} goes to player.aspx mysite.com/{TeamName} goes to team.aspx … and so on …

Could somebody point in the right direction of achieving this with asp.net. Is it possible using the built in routing engine, or should I be looking to code my own HTTPModule for this?

Thanks David

Requests to my API were going swimmingly until I had to POST data. API is expecting JSON so I changed my content-type to application/json, and this causes all CORS implementations to require preflights, and now I'm getting 405. Thing is, request/response looks good. Request headers accept, content-type are in the Access-Control-Request-Headers. Request method POST, POST and PUT allowed. Access-Control-Allow-Origin allowing all origins. What gives?

Remote Address: -
Request URL: -
Request Method: OPTIONS
Status Code: 405 Method Not Allowed
Request Headers
  Accept: */*
  */// for the sake of syntax highlighting
  Accept-Encoding: gzip,deflate,sdch
  Accept-Language: en-US,en;q=0.8
  Access-Control-Request-Headers: accept, content-type
  Access-Control-Request-Method: POST
  Cache-Control: no-cache
  Connection: keep-alive
  Host: -
  Origin: http://localhost
  Pragma: no-cache
  Referer: http://localhost/
Response Headers
  Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
  Access-Control-Allow-Origin: *
  Allow: POST,PUT
  Cache-Control: no-cache
  Content-Length: 76
  Content-Type: application/json; charset=utf-8
  Date: Wed, 01 Oct 2014 19:43:56 GMT
  Expires: -1
  Pragma: no-cache
  Server: Microsoft-IIS/8.0
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET

I am trying to write out an Excel .xls file from Internet Explorer. One way, that is working, is to have an asp:ImageButton's click event do the job. It is this:

    protected void imgExport_Click(object sender, EventArgs e)
    {

        GridView gv = new GridView();
        gv.DataSource = list; // assume this has my data
        gv.DataBind();

        Response.Clear();
        Response.ContentType = "application/ms-excel";
        Response.AddHeader("content-disposition", "attachment;filename=RoamingPartners.xls");

        StringWriter swriter = new StringWriter();
        HtmlTextWriter hwriter = new HtmlTextWriter(swriter);

        gv.RenderControl(hwriter);

        Response.Write(swriter.ToString().Replace("&lt;br/&gt;", " "));
        swriter.Close();
        hwriter.Close();
        Response.End();
    }

As stated, this works, and writes out my file.

However, I don't want to use an asp server control. Instead, I turn the above into a WebMethod and make an ajax call via jQuery. Note that this is similar to the above method, except I must use HttpContext.Current.Response instead of Response:

    [WebMethod]
    public static void ExportData()
    {

        GridView gv = new GridView();
        gv.DataSource = list; // assume this has my data (I use country param to get it)
        gv.DataBind(); 

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "application/ms-excel";
        HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=RoamingPartners.xls");

        StringWriter swriter = new StringWriter();
        HtmlTextWriter hwriter = new HtmlTextWriter(swriter);

        gv.RenderControl(hwriter);

        HttpContext.Current.Response.Write(swriter.ToString().Replace("&lt;br/&gt;", " "));
        swriter.Close();
        hwriter.Close();

        HttpContext.Current.Response.End();
    }

For good measure, my ajax call:

 $.ajax({
        type: "POST",
        url: "Default.aspx/ExportData",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            alert("success");
        },
        failure: function (response) {
            alert("failure");
        }
    });

The problem is that this throws a "Thread was being aborted." exception. Someone suggested catching the exception, but I still did not get my file. Another suggestion was to use HttpContext.Current.ApplicationInstance.CompleteRequest() instead of HttpContext.Current.Response.End(), but this also doesn't write out the file. How do I get this to work?

I'm facing a problem with Google maps Reverse geocoding. I wrote a web page on ASP.NET that interacts with google maps and a GPS module. GPS positions are stored on the web Server on an SQL Server Database.

Now I need to add clients the posibility of query the web server with an specific GPS module and a Period of time, to show on a grid all the positions reported by GPS module. To do this, I have an Stored procedure on SQL server wich filter the data and then send it to client with ASP.NET. The result is shown on a paginated DataGrid. I need also the ability of export the result to excel. So far so good.

Now the problem comes with the need of reverse geocoding the positions (convert Lat and Long to real address).

My original idea was that when the table get filled, i could create a javascript function that for each row calls a function to interrogate google for the reverse geocode and fill the missing field on the table (all this from JavaScript/Client side). The problem with this approach comes with the export part. On Client side I only have one page of data to geocode, but i need to export the whole query! I need to take in account the time to proccess al the positions.

This is the ASP.NET code I use to export the XLS file

Private Sub ExportToExcel(ByVal nameReport As String, ByVal wControl As GridView, ByVal sTitle As String)
        Dim responsePage As HttpResponse = Response
        Dim sw As New StringWriter()
        Dim htw As New HtmlTextWriter(sw)
        Dim pageToRender As New Page()
        Dim form As New HtmlForm()

        wControl.AllowPaging = False
        wControl.EnableViewState = False
        wControl.DataSource = GetDataSource()
        wControl.DataBind()

        wControl.Caption = "<strong>" + sTitle + "</strong>"
        form.Controls.Add(wControl)
        pageToRender.Controls.Add(form)
        responsePage.Clear()
        responsePage.Buffer = True
        responsePage.ContentType = "application/vnd.ms-excel"
        responsePage.AddHeader("Content-Disposition", "attachment;filename=" & nameReport)
        responsePage.Charset = "UTF-8"
        responsePage.ContentEncoding = Encoding.Default
        pageToRender.RenderControl(htw)
        responsePage.Write(sw.ToString())
        responsePage.End()
    End Sub

Is this the best way of doing this? Any ideas on new approach will be of great help!

Thanks!

Ok so im trying to make this following error: An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code

Additional information: Incorrect syntax near the keyword 'Table'.

    protected void Button_Login_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RegisterConnectionString"].ConnectionString);
        conn.Open();
        string checkuser = "select count(*) from [Table] where Användarnamn='" + TextBoxAnvändarelogin.Text + "'";
        SqlCommand com = new SqlCommand(checkuser, conn);
        int temp = Convert.ToInt32(com.ExecuteScalar().ToString());
        conn.Close();
        if (temp == 1)
        {
            conn.Open();
            string checkPasswordQuery = "select password from Table where Användarnamn='" + TextBoxAnvändarelogin.Text + "'";
            SqlCommand passComm = new SqlCommand(checkPasswordQuery, conn);
            string password = passComm.ExecuteScalar().ToString().Replace(" " , ""); // ERROR HERE!
            conn.Close();
            if (password==TextBoxLösenordlogin.Text)
            {
                Session["New"] = TextBoxAnvändarelogin.Text;
                Response.Write("Lösenord är rätt!");
                Response.Redirect("Admin.aspx");
            }
            else
            {
                Response.Write("Lösenord är fel!");
            }
        }
        else
        {
            Response.Write("Användarnamn är inte rätt!");
        }

    }
}

I have this method that should take an unknown amount of id's. I got this method almost done but it isnt secure yet for obvious reasons, i know i could write my own method to strip the parameters but i would be more comfortable by using some build in method for this.

Here is the method

public static List<LocationModel> FetchCitiesByAreas(IEnumerable<string> areas)
    {
        using (var db = new BoligEnt())
        {
            var sqlQuery = new StringBuilder();
            var first = true;

            sqlQuery.Append("SELECT DISTINCT a.city AS City, a.zip AS Zip ");
            sqlQuery.Append("FROM zip_city AS a ");
            sqlQuery.Append("WHERE country = 1 ");

            foreach (var d in areas)
            {
                if (first)
                {
                    sqlQuery.Append("AND a.area_id = '" + d + "'");
                    first = false;
                }
                else
                {
                    sqlQuery.Append("OR a.area_id = '" + d + "'");
                }

            }

            return db.Database.SqlQuery<LocationModel>(sqlQuery.ToString()).ToList();
        }
    }

i know it have this function built in but as i stated earlier i dont know the exact amount of ids that will come in

db.Database.SqlQuery<LocationModel>("SELECT * FROM table WHERE id = @p0 ;", id).ToList();

Thanks

I try to understand how Backbone work and what is the best form of do a modular code. I am making a app with different pages. In one of this page I have two different part, one tree and one list. I need to use the same tree in a future page, and this is the problem. How can do it?

I'm thinking in different extent of the same model. But I don't know if I can do this. In another way I can do different model for the different part of the page.

What is the best form to do this?

Thank you

I am pretty new at ROR, I am currently building an simple platform application, where users can go login to their on dashboard and sign up for services. Now I have several pages that is just for information for the users only, like welcome page, or the how_to page. I would like to restrict access these pages to be only accessed after the user signed in.

my question is, do i need a separate action in my UserController, to display link to these view templates? for example

class UsersController < ApplicationController


    def welcome
    end

    def howto
    end
end

here is my route file.

resources :users
resources :sessions, only: [:new,:create,:destroy]

root 'main#index'
match '/pro', to: 'main#pro', via:'get'


match '/signup',  to: 'users#new',            via: 'get'
match '/signin',  to: 'sessions#new',         via: 'get'
match '/signout', to: 'sessions#destroy',     via: 'delete'

EDIT:

Okay I think I am starting to get the picture now.. In my case, There wouldnt be conditional content for the same view template, the dashboard templates have a completely different layout and structure than my public view templates. I can restrict access to my whole controller that would require user to sign In before view. My question still persists. If I have a bunch of view templates for authorized user only, Do i need to make a new action for each of those template in my restricted controllers?

I have a nested looped tables below and I want to access an element inside the <td> element which is a <div> element named divrep which is currently closed.

I want to access this div element when the input button named Reply is clicked so that I can open it. I have a JavaScript code below to open it but it will always open the first row.

How do I open it in an exact index of the row of the table based on the index where the clicked input button is located? So far, this what I have:

function OpenReply() {
    var div = document.getElementById("divrep");
    div.style.display = "block";
}

<table id="mytable">     

    @foreach (var item in Model.Comments )
    {
        <tr >
            <td class="tdstyle" >
                <div >  @Html.DisplayFor(modelItem => item.name) </div> 
                <p>  @Html.DisplayFor(modelItem => item.comment) </p>
                <p> <input type="button" id="Reply" name="Reply" value="Replie(s)" onclick ="return OpenReply()" /> </p>

                <div id="divrep" style="display:none>
                    <table>
                    @foreach (var item2 in Model.Replies.Where(r => r.idrep == item.Id))
                    {
                        <tr >
                            <td >
                                <div> @Html.DisplayFor(modelItem => item2.namerep) </div> 
                                <p >@Html.DisplayFor(modelItem=>item2.reply)  </p>
                            </td>
                        </tr>
                    } 
                    </table>           

                    @using (Html.BeginForm("PostComment", "Profile", FormMethod.Post, new { }))
                    {
                        <div class="editor-field" style="display:none; margin-bottom:5px;margin-top:5px">
                            <input type="text" id="comidvalue" name="idrep" value="@Html.DisplayFor(modelItem=>item.Id)" />
                            <span class="field-validation-valid" data-valmsg-for="idrep" data-valmsg-replace="true"></span>
                        </div>
                        <br />
                        <input type="text" id="namerep" name="namerep" />
                        <span class="field-validation-valid" data-valmsg-for="namerep" data-valmsg-replace="true"></span>
                        <br />
                        <textarea id="reply" name="reply" style="width:445px;height:100px;resize:none" ></textarea>
                        <span class="field-validation-valid" data-valmsg-for="reply" data-valmsg-replace="true"></span>
                        <input type="submit" value="Post Reply" name="butname" />
                    }
                    <br />
                </div>
            </td>       
        </tr>
    }

</table>

I can add htmlAttributes like following and its rendered in Html

@Html.EditorFor(Function(model) model.LastName, New With {Key .htmlAttributes = New With {Key .ng_model = "model.LastName"}})

But when I added a custom editor template for Date Data type in the Views\Shared\EditorTemplates\Date.vbhtml as follows

@Code
    Dim value = ""
    If Not Model Is Nothing Then
        value = String.Format("{0:d}", Model.Value.ToString("dd/MM/yyyy"))
    End If
    @Html.TextBox("", value, New With {Key .class = "datefield", Key .type = "text"})
End Code

and I use the EditorFor with htmlAttributes then the HtmlAttributes are not rendering?

I'm trying to set modal title with jQuery. I want the title to be: text + tiny profile picture + text.

This is what I've tried so far:

$(".ModalTitle").text('textblabla' + @Html.Raw("<img src=\"image.png\" />") + textblabla);

This doesnt give me any errors but when i start the website and check the console it says: Uncaught SyntaxError: Unexpected token <

How can this be solved?

Thanks

Edit 1:

I don't think I'm escaping the last " after the image url..

I am using the Telerik.MVC.Grid (version 2013.2.611) from Nuget

The following script

function mouseDown(e)
{
    var grid = document.getElementById("ColumnsEditor")
    grid.submitChanges();
}

throws error: Object doesn't support property or method 'submitChanges'

Documentation indicates this is a valid method. If the method is invalid, is there an alternative method to call.