I need to quickly execute stored procedure which updates table with data from different data source in SQL Server. Is it possible to do it with EF7, I have tried FromSql, but this seems to only works with the mapped entities.

It doesn't need to return anything, just execute.

Is there any other method than using SQLConnection, or SQL job running every 10 minutes on the server?

I am trying to implement Login with twitter in my ASP.NET webforms application. I want to implement it similar to how the javascript api works for Google+ and Facebook (open a popup on the website without redirecting from the website). I have implemented this for ASP.NET MVC using DotNetOpenAuth.AspNet.Clients.TwitterClient class using the following code:

public ActionResult TwitterLogin()
{
    TwitterClient client = GetTwitterClientObj();
    UrlHelper helper = new UrlHelper(this.ControllerContext.RequestContext);
    var result = helper.Action("TwitterLoginCallBack", "Account", null, "http");
    client.RequestAuthentication(this.HttpContext, new Uri(result));
    return new EmptyResult();
}

//This function will be called after user is authenticated by twitter
public ActionResult TwitterLoginCallBack(string returnUrl)
{
    TwitterClient client = GetTwitterClientObj();
    var result = client.VerifyAuthentication(this.HttpContext);
    return RedirectToAction("TwitterLoginPopup", new { isLoginSuccessful = result.IsSuccessful, twitterId = result.ProviderUserId, screenName = result.UserName });// Calling another function and passing the retrieved data
}

private TwitterClient GetTwitterClientObj()
{
    return new TwitterClient(ConfigurationManager.AppSettings["twitterConsumerKey"], ConfigurationManager.AppSettings["twitterConsumerSecret"]);
}

window.open javascript code for to call TwitterLogin action method mentioned above:

$("#loginWithTwitter").click(function () {
        var screenLeft = 0, screenTop = 0;
        if (typeof window.screenLeft !== 'undefined') {
            screenLeft = window.screenLeft;
            screenTop = window.screenTop;
        } else if (typeof window.screenX !== 'undefined') {
            screenLeft = window.screenX;
            screenTop = window.screenY;
        }
        var left = screenLeft + ($(window).width() - 600) / 2;
        var top = screenTop + ($(window).height() - 600) / 2;
        var myPopup = window.open(baseurl + 'TwitterLogin', "popupWindow", "width=600, height=600, scrollbars=yes, left=" + left + ", top=" + top);
    });

The above code works fine in the MVC application but I want to implement this exact functionality in a WebForms application. I have found examples with other third party libraries but they redirect the user from current website to twitter.com which I do not want. Any other way to implement this functionality in a WebForms application?

In VS2015 we are no longer able to add aspx MVC views to MVC project. Anyone knows how to add ASPX MVC View in Visual Studio 2015?

let say I enter a code into textbox 100 but into label Pizza should be texted in label

protected void Page_Load(object sender, EventArgs e)
{

}

protected void txtMain_TextChanged(object sender, EventArgs e)
{        
   lblmain.text = txtcat.text;
}

I'm using jansy bootstrap to replace the asp.net FileUpload. I've successfully retrieved the file using HttpPostedFile with the help of this answer:

HttpPostedFile image = Request.Files["myFile"];

Now, how do I allow multiple files to be selected? With the asp.net FileUpload it was simply adding AllowMultiple="True" parameter and then in the code behind I simply looped through:

foreach (var image in FileUpload1.PostedFiles)
{...}

How do I do this with a custom control? THis is my current html (which is the first Image Upload Widget example):

<div class="fileinput fileinput-new" data-provides="fileinput">
    <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
    <div>
        <span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span>
          <input type="file" id="myFile" name="myFile"></span>
        <a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
    </div>
</div>

I have a class library project consisted purely of xml files with build action set to Embedded resource. Application reads these files during startup.
When I build this project inside VS 2010, deploy this project to IIS, application starts very slowly ( > 5 min).
When I open same solution with VS 2012, build class library project and deploy dll to IIS, application starts for ~20 seconds.
Inspection of both dll-s with ILSpy didn't find any differences. Also, dlls size is identical. This is profiler trace of slow startup:

enter image description here

Any ideas what could be the cause this issue?

Thanks.

Hi I want to delete record form XML file on the click of asp.net button. But is generated on runtime from AngularJS

Below is my XML file which I use to display data in table format

<UserDetail>
  <Detail>
    <EmployeeID>124578</EmployeeID>
    <EmployeeName>suresh</EmployeeName>
    <EmailID>suresh@xyz.com</EmailID>
  </Detail>
  <Detail>
    <EmployeeID>587458</EmployeeID>
    <EmployeeName>Vivek</EmployeeName>
    <EmailID>vjain@xyz.com</EmailID>
  </Detail>
</UserDetail>

Here is my HTML code with that my data coming in table format

<div ng-app="myApp" ng-controller="myCtrl">
            <table border="1" width="100%">
                <tr>
                    <th>Employee ID</th>
                    <th>Employee Name</th>
                    <th>Email ID</th>
                    <th>Status</th>
                </tr>
                <tr ng-repeat="detail in details" align="center">
                    <td>{{detail.EmployeeID}}</td>
                    <td>{{detail.EmployeeName}}</td>
                    <td>{{detail.EmailID}}</td>
                    <td>
                        <asp:Button CssClass="btnDelete" Text="Delete Record" runat="server" ng-click="getID(detail.EmployeeID)" OnClick="btnDelete_Click"/>
                    </td>
                </tr>
            </table>
        </div>

Here is my AngularJS code with that I m get changing XML to JSON and present in the form of table

<script>
        var app = angular.module('myApp', []);
        app.controller('myCtrl', function ($scope, $http) {
            $http.get('myDB.xml')
            .then(function (response) {
                var x2js = new X2JS();
                $scope.details = [];
                var data = x2js.xml_str2json(response.data);
                $scope.details = data.UserDetail.Detail;
                $scope.getID = function (id) {                 
                    if (this == id)
                    {
                        $scope.UserDetail.Detail.splice(index, 1);
                    }
                }
            });

        });
      </script>

My Delete Record button code

protected void btnDelete_Click(object sender, EventArgs e)
{
    var xDoc = XDocument.Load(@"D:\test\myDB.xml");
    xDoc.Descendants("Detail")
       .Elements("EmployeeID")
       .Where(x => x.Value == id)
       .Remove();
    xDoc.Save(@"D:\test\myDB.xml");
}

Help me to delete record from XML file

My Model --------->

public class RegistrationModel { [Key] public int Id { get; set; }

    [Required]
    public string FirstName { get; set; }

    [Required]
    public string LastName { get; set; }

    [Required]
    public string LoginName { get; set; }

    [Required]
    [DataType(DataType.Password)]
    public string Password { get; set; }

    [Required]
    public string Email { get; set; }

    //[Required]
    public DateTime LoginTime { get; set; }

    [Required]
    public Boolean Active { get; set; }

    [Required]
    public int RoleId { get; set; }
    public List<AppRole> RoleList { get; set; }

}

public class AppRole
{
   public int RoleId { get; set; }
   public string Role { get; set; }
}

}

My Controller -------------->

[HttpGet] public ActionResult EditUser(int id) { var model = new RegistrationModel(); var _roleList = _userManager.GetRoles(); var roleList = new List();

        foreach (var role in _roleList)
        {
            roleList.Add(new AppRole
            {
                RoleId = role.Id,
                Role = role.Name
            });
        }
        model.RoleList = roleList;

        if (id == null)
        {
            return PartialView("_EditUser", null);
        }
        else
        {
            var userData = _userManager.GetDetailsById(id);
            if (userData == null)
            {
                return HttpNotFound();
            }

            return PartialView("_EditUser", userData);
        }
    }

    [HttpPost]        
    public JsonResult EditUser(RegistrationModel userDetails)
    {
        var userdata = _userManager.GetDetailsById(userDetails.Id);
        userDetails.LoginTime = userdata.LoginTime;
        userDetails.Password = userdata.Password;
        userDetails.RoleId = userdata.RoleId;
        userDetails.Active = userdata.Active;
        _userManager.Update(userDetails);
        var msg = "User data Updated";
        return Json(msg, JsonRequestBehavior.AllowGet);
    }

My View --------->

Role* @Html.DropDownListFor(m => Model.RoleId, new SelectList(Model.RoleList, "RoleId", "Role"), new { @class = "form-control" })

problem is that my dropdown is not visible. if i didn't added this dropdown its giving the remaining fields properly. and also same dropdown is working fine for CreateUser(ActionName). Hope you people help

I'm having a problem with loading difference views by using @Html.ActionLink. I've attached some screen shots here to explain the problem.

enter image description here

when I click on the "Home" button Its loading properly, But when I click on the "Contact" button its load the page but JavaScript, jQuery NOT Working

 @{
             Html.Raw("<li class='k-block'>");  

             @Html.ActionLink("Home", "Index", new { controller = "Home" }, new { @class = "k-button" }) 

                 Html.Raw("</li>");

             Html.Raw("<li class='k-block'>");  

             @Html.ActionLink("Contact", "Contact", new { controller = "Home" }, new { @class = "k-button" }) 

             Html.Raw("</li>");

enter image description here

Can you please tell me what would be the mistake I've made..

I want to create gridview with code. My code is:

 GridView gdvList = new GridView();
 gdvList.ID = "gdvList" ;
 TemplateField tField = new TemplateField();
 BoundField dateBF = new BoundField();
 dateBF.DataField = "Date";
 gdvList.Columns.Add(dateBF);
 BoundField countResponse = new BoundField();
 countResponse.DataField = "CountResponse";
 gdvList.Columns.Add(countResponse);
 ObjectDataSource ods = new ObjectDataSource();
 ods.ID = "ods";
 ods.TypeName = "Project.BLLQuestion";
 ods.SelectMethod = "GetByGroupID";
 ods.SelectParameters["GroupID"] = new Parameter("inGroupID", DbType.Int32, "0");
 ods.DataBind();
 gdvList.DataSource = ods;
 gdvList.DataBind();    

this code does not work, and how to add TemplateField do :

<asp:TemplateField ItemStyle-CssClass="GridItemTemplateField">
    <ItemTemplate>
         <a href="Question.aspx?id=<%# Eval("ID")%>"><%# Eval("Content").ToString().PadRight(140).Substring(0,140).TrimEnd()+"..." %></a>
    </ItemTemplate>
</asp:TemplateField>

how can do it?

Currently one of my application is having issue with "Access Denied" when creating folder in their server. Since the server is not manage by me, I couldn't access to check on the permission issue and stuff.

I know this is all about permission issue. Everything works fine on my side.

I'm just think if there is any way I could squeeze more from this UnauthorizedAccessException so that I'm able to find what type of access denied issue it is. As in which user is not given the necessary permission, what permission is lacking and etc.

For now, this is the full Stack Trace but it doesn't help to know the root cause

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) at System.IO.File.Create(String path) at SampleProject.Code.ExceptionTest.btnTriggerEx_Click(Object sender, EventArgs e) in C:\Users\Admin\Desktop\Desktop 20150824\Desktop\Main\Programming\SampleTest\SampleProject\SampleProject\Code\ExceptionTest.aspx.cs:line 38

Please advice.

Thanks

Background

My backend has a database in SQL server 2012 which has around 20 tables (maybe will increase in time) and each table will have approx 100 - 1000 rows initially might increase in future.

Now one of my colleague developed an web application which uses this database and let clients do CRUD and usual business logic.

Problem

My task is to create a reporting page for this web application, what I will be doing is to give client ability to export all of the data for all of there deep nested objects from SQL from all tables or only couple with all columns or only few... in excel, pdf and other formats in future. I might also need to query 3rd party in my business logic for gathering further information (out of context for now).

What can I do to achieve above ?

What I know

I can't think of any efficient and extendable solution, as it will involve 100s of columns and 20s of tables. All I can think of adding 100s of views for what I might require but it doesn't sound particle either.

Should I look into BI or SQL reporting or should this be done in code using ORM like EF ? or is there any open source code already out there for such Generic operations I am totally confused.

when i bind data to the listpicker, i get name displayed in selected item, but when the dropdown shows the whole item will be myProject.MyClass....something i am new to windows phone application development.. Can anyone help me with this?

here is my xaml code

<toolkit:ListPicker Header="Select Name" Name="listName" Tap="listName_Tap" VerticalAlignment="Center">
   <toolkit:ListPicker.ItemTemplate>
        <DataTemplate>
            <StackPanel>
            <TextBlock Text="{Binding name}"/>
            </StackPanel>
        </DataTemplate>
      </toolkit:ListPicker.ItemTemplate> 
</toolkit:ListPicker>

Here is my c# code

class MyClass
{
    public String name{ get; set; }
}

private void sendPostCompleted(object sender, UploadStringCompletedEventArgs e)     
{
    //e.result is my json string obtained from webservice([{name:hhh}{name:jkj}{name:jack}])
    var data = JsonConvert.DeserializeObject<MyClass[]>(e.Result.ToString()); 
    listName.ItemsSource = data;
}

In AspNet5 rc 1, web application project For loading of html / js pages,

  1. by default aspx pages are not supported.

    app.UseStaticFiles()

this allows to browse static html files. how to add web form, aspx functionality (dnx451, dnxcore50)

  1. What are the allowed file extensions / mimetypes in aspnet5 by default. Asking this because, after adding static files functionality, calling that website/test.html page loads fine , but browsing website/test.aspx returns 404 but the pages are available under wwwroot folder inside the project

While solving an issue in aspx, I got stuck while setting a backbone property from the ASP.Net session variable.

I want to set a property with value that contains '\u' in character in between. Like

  App.prop.set("Username",<%= Session.Name %>)

Session.Name contains "john\udenver" as value, When I put debugger in javascript and check the value its escaped \u correctly as "john\udenver"

where Session.Name already has the escaped value of "john\udenver".

but when renders ans trying to assign to value to property it is unescaping \u I get an exception saying "Error:Expected hexadecimal digit."

I tried to escape using "escape" method

App.prop.set("Username", escape ("<%= Session.Name %>")) 

but it throws same exception, it renders as

App.prop.set("Username", escape ("john\udenver")) 

I think while rendering the page it gets changed to "john\udenver" and throws the exception.

One of the workarounds can be to put RegEx check before <%= Session.Name %>.

App.Prop.set("Username","<%= System.Text.RegularExpressions.Regex.Escape(NFSessionObject.Username )%>");

But this does not seem to be the cleanest of ways. Need help to set and get this property in the page with \u or \x present in the string. Can you please suggest.

Thanks.

I'm writing up a DNX-based portable class library that I want to be used on all platforms. Here is its project.json:

{
    "title": "flavor.net",

    "dependencies": {
        "Be.IO": "1.0.0"
    },

    "frameworks": {
        ".NETPortable,Version=v4.5,Profile=Profile259": {
            "frameworkAssemblies": {
                "System.Collections": { "type": "build" },
                "System.IO": { "type": "build" },
                "System.Linq": { "type": "build" },
                "System.Runtime": { "type": "build" }
            }
        }
    }
}

Here is the unit tests' project.json (I'm using the xUnit.net testing framework):

{
    "dependencies": {
        "flavor.net": "",
        "VideoLibrary": "1.3.3",
        "xunit": "2.1.0",
        "xunit.runner.dnx": "2.1.0-rc1-build204"
    },
    "commands": {
        "test": "xunit.runner.dnx"
    },
    "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
    }
}

When I attempt to build this, I'm getting several errors saying things like The dependency fx/System.Collections could not be resolved for all of the System dependencies in the first file. The weird thing is, that project itself seems to be building fine, but it's the unit test project that is causing errors.

Here's a screenshot for extra clarity:

Why is this happening and what can I do to fix it? I'm using VS 2015 Update 1 and my DNX version is 1.0.0-rc1-update1.

I'm getting this error in my Web Application in the SGEN file, after I add a web reference to a third party tool.

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

I found this solution but I don't believe that app.config can be added to a Web App. Mixed mode assembly is built against version 'v1.1.4322'

I added this to the web.config but it didn't help.

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" />
</startup>

I also added this to the sn.exe.config file, but that didn't help either:

<startup useLegacyV2RuntimeActivationPolicy="true"> 

Anyone have any ideas?

I am building an ASP.NET MVC 5 "To Do List" app, where users can add categories and add tasks to categories. I am using Entity Framework 7 with a sort of "Code First" approach, but using an existing database.

I created a database in Microsoft SQL Server Management Studio with a Category and an Item table, and each Item has a CategoryId column that is a foreign key to the Category's Id column.

Then I created an empty MVC5 app, with a database connection to this database. I created an Item class and a Category class in the Models folder that correspond to the tables in the database.

Item class:

namespace ToDoList.Models
{
    [Table("Item")]
    public partial class Item
    {
        public int ItemId { get; set; }
        public string Description { get; set; }

        [ForeignKey("Category")]
        public int CategoryId { get; set; }

        public virtual Category Category { get; set; }
    }
}

Category class:

namespace ToDoList.Models
{
    [Table("Category")]
    public partial class Category
    {
        public Category()
        {
            this.Items = new HashSet<Item>();
        }

        public int CategoryId { get; set; }
        public string Name { get; set; }
        public virtual ICollection<Item> Items { get; set; }
    }
}

I want the view for an Item to display its Category's Name property. The model for the view is a collection of all Items in the Item table (IEnumerable<ToDoList.Models.Item>). Say I want to print a list with each item followed by the name of the category related to it. Here's the code that I have:

    <ul>
    @foreach(var item in Model)
    {
        <li>@Html.DisplayFor(modelItem => item.Description) @Html.DisplayFor(modelItem => item.Category.Name)</li>;

    }
    </ul>

The Item shows up just fine, but the page doesn't display anything for the Category. This same code actually worked when I used an ADO.NET Entity Data Model to create classes, but I'm not able to create an Entity Data Model using ASP.NET 5, so I'm trying out this code-first approach.

Any ideas on why the app isn't using the foreign key relationship or suggestions of what I can try?

i have a really silly question but i cant find my self to know why Visual Studio give me this Error.

I maked a filter Text box in my View and i pass the String to my controller to make a where statement using one of my Model Strings and i get the error on my model String saying its not Invocable.. This is my View part of textbox

@using (Html.BeginForm())
{ 
<p>
    Filtro Descripcion: @Html.TextBox("SearchString")
    <input type="submit" value="Seach" />
</p>
}

This is my model:

 public partial class Pos
    {
        public System.DateTime Fecha { get; set; }
        public string Rid { get; set; }
        public string Pdv { get; set; }
        public string Pla { get; set; }
        public string Descripcion { get; set; }
        public decimal Total { get; set; }
        public int Cantidad { get; set; }

        
    }

And this is my controller Index Method that give me the error on my where statement

 public ActionResult Index(string searchString)
        { 
            var db = new ArponClientPosContext();
            var students = from s in db.Pos
                           select s;
            if (!String.IsNullOrEmpty(searchString))
            {
                db = db.Pos.Where(s => s.Descripcion(searchString));
            }

            return View("~/Views/HomePos/Index.cshtml", db.Pos.ToList());
           
        }

exactly this part : db.Pos.Where(s => s.Descripcion(searchString)); it says "Description" is not an invocable object

Can someone explain my why i have this problema or what did i did wrong? Any help wil be apreciated

I have experience with .net, but never seen in my life salesforce.

Can anyone guide me in the right directio to insert data into sales force leads?

I guess its a webservice, but which endpoint, which parameters?

thanks a lot

I tried write code what is working in MVC 4 using VS2012.

RouteConfig.cs

namespace MvcApplication2012
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "SayHello",
                url: "hello",
                defaults: new { controller = "hello" }
                );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}

IController.cs

namespace MvcApplication2012.Controllers
{
    public class HelloController : IController
    {
        public void Execute(System.Web.Routing.RequestContext requestContext)
        {
            requestContext.HttpContext.Response.Write("Hello, world!");
        }
    }
}

This code works fine in MVC 4 using VS2012, but not work in MVC 5 using VS2015.

What is defference? Why it not work?

Returns error enter image description here