I have a database which contains different records and I want to display these record on my asp.net page but I dnt want to use grid view for this purpose. I want to display them in tiles format so that in each row multiple records can be displayed and I have more than 200 records.If you have any solution then please help me to solve this problem. If you dnt understand my questin then please vist royalwatches.pk thanks

In MVC 4 I ended up overriding the controller factory to allow my ApplicationDbContext to be injected into each controller as it was instantiated. I was sure that throughout my requests I would never have two references to my ApplicationDbContext which ensured I didn't have any multithreading issues.

Now that MVC 5 is here, what's the proper way of implementing the repository pattern with OWIN? I've heard with OWIN that it creates a new UserManager / ApplicationDbContext per request. If this is true, then I would like to use the database context in my controllers / repositories. Is it possible to pass the database context into a controller? (Something to the lines of HttpResponse.GetOwinContext.Environment["owin.DatabaseContext"] ??)

There seems to be a half-finished question here that doesn't have an answer to the question: OWIN DbContext and a single DbContext for all of my Repositories. (also one here: Owin Context to use a single instance per request) Any guidance is appreciated.

Timer_Tick

    private void timer1_Tick(object sender, EventArgs e)
    {
        lblTotalTimer.Text = hour + ":" + min + ":" + sec + ":" + ms.ToString();
        ms++;
        if (ms > 10)
        {
            sec++;
            ms=0;
        }
        else
        {
            ms++;
        }
        if (sec > 60)
        {
            min++;
            sec = 0;
        }
        if (min > 60)
        {
            hour++;
            min = 0;
        }
    }

Function from which I am calling timer1.start

    private void btnSend_Click(object sender, EventArgs e)
    {
        //backgroundWorker1.RunWorkerAsync();
        if (txtNickName.Text != "")
        {
            if (WhatsAppUsers != null)
            {
                if ((gridReceiver.RowCount - 1 != 0) && (gridSender.RowCount - 1 != 0))
                {
                    TimerStart();
                    SendWhatsAppMsg();
                    lblSendingTo.Text = "Null"; 
                }
                else
                {
                    txtLog.Text += "Sender or Receiver Missing";
                }
            }
            else
            {
                txtLog.Text += "Please Click Check For Whatsapp Authenticated User\n";
            }
        }
        else
        {
            txtLog.Text += "Please Enter Nickname\n";
        }
        timer1.Stop();
        timer1.Enabled = false;
    }

When I call same thing by creating a button it works Like if I create start Button and Stop Button separately and then calling timer1.start() and timer1.stop() it works but when I call same thing from this class it dint I have already tried creating another class and calling that class for timer1.start()

I am trying to use mySqlSessionStateProvider for handling session with mysql. below is the web.config

<sessionState cookieless="true" regenerateExpiredSessionId="true" mode="Custom" customProvider="MySqlSessionStateProvider">
  <providers>
    <add name="MySqlSessionStateProvider" type="MySql.Web.SessionState.MySqlSessionStateStore, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="/test" description="test description" connectionStringName="mysql" writeExceptionsToEventLog="True" autogenerateschema="True" enableExpireCallback="False" />
  </providers>
</sessionState>

When running the application the database schema is being auto-generated and in the sessionId column, the current session is being added up. and the sessionId is also added with the url which i don't want. I want to use cookie to store the sessionId. Therefore in web.config i changed cookieless="true" to cookieless="false". But then when running the application i can't see the sessionId for the current request in the table my_aspnet_sessions. I guess, i have to manually create the cookie that store the sessionID ,save it to my_aspnet_sessions and send it with response. and later have to retrieve it with Request. or this happens by itself ? in that case how do i retrieve the sessionId from the cookie? Help needed to clear my doubts. Some code would be helpful in this context.

I have a Html page which is to be converted to PDF on button click . The Problem is I have a Gridview On This Page having set AutoGenerateColumns is true . PDF is generating fine but all the rows in the gridview are not getting generated by pdf. suppose if my grid view contains 1000 rows my PDF generating just 20 to 30 records . how to Overcome this problem . Without using itextsharp all the rows are generating but problem is not styling on generated page.

    <div style="text-align:center; width:100%;">
        <asp:GridView ID="gvViewReports" Width="100%" AutoGenerateColumns="true" ShowHeader="true" CellPadding="5" runat="server" AllowPaging="false">
            <EmptyDataTemplate>
                <div style="background-color: #e9f8ff;color: #5d9fa9;border: 1px solid #75c7d3; font-family: Arial, sans-serif;font-size: 12px;line-height: 18px;margin-bottom: 15px;position: relative;padding: 14px 40px 14px 18px;">
                    <strong>No Information Available For Search Criteria</strong>
                </div>
            </EmptyDataTemplate>
            <HeaderStyle BackColor="#5d9fa9" ForeColor="White" Font-Size="12px" />
            <AlternatingRowStyle BackColor="#f9f9f9" Font-Size="12px" Width="15px"/>
            <RowStyle Font-Size="12px" Width="15px" />
        </asp:GridView>
    </div>
</div>

public void GeneratePDF(string text)
    {
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.Clear();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        this.Page.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());
        Document pdfDoc = new Document(PageSize.A4);
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        writer.PageEvent = new PDFTemp();
        pdfDoc.Open();
        //htmlparser.Parse(sr);
        iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
        pdfDoc.Close();
        string fileName = string.Format("{0}{1}",text, DateTime.Now.ToString());
        //string fileName = string.Format("{0}", text);
        Response.AppendHeader("Content-Disposition", "attachment;Filename=" + fileName + ".pdf");
        Response.Write(pdfDoc);
        Response.End();
    }

I am using Dotnet Highchart with Jdash to implement dashboard for my project, After Adding new chart all charts in the dashboard disappear including the new one, If I refreshed the page they appear again. also if I changed the setting of any chart I got the same result, Although that all thing work well, no exceptions, the generated javascript code form Dotnet Highchart is the same one generated after refresh, after adding chart.

Any Idea about this issue?

I have a webform that queries an Access database for journal entries and gives various statistics about them; such as giving me the total number of journal entries and total number of journal entries for a specific topic. What I would like is to be able to enter a start date and an end date and the total number of journal entries that fall between those two dates would be calculated.

So far I have two textboxes with a jquery calendar but when two dates are selected and the search button is clicked, it's not picking up the right number of journal entry totals and returns 0.

The datetime picker puts the date into a format like this: mm/dd/yyyy and the Access database has the JournalDate field formatted as Date/Time. In other words, the Access database holds the dates as 4/8/2014, and the DataTime Picker displays them in the textbox as 04/08/2014. I thought converting them with parse would do the trick but it still returns 0 for the total number of journal entries when dates are selected. Any help would be very much appreciated.

It's also open to SQLInjection right now.

DateTime StartDate = DateTime.Parse(txtStartDate.Text);
DateTime EndDate = DateTime.Parse(txtEndDate.Text);

using (OleDbConnection con = new OleDbConnection(constr))
    using (OleDbCommand com = new OleDbCommand("SELECT * FROM JournalEntries WHERE JournalDate BETWEEN " + txtStartDate.Text + " and " + txtEndDate.Text, con))
    {
        con.Open();
        using (OleDbDataReader myReader = com.ExecuteReader())
        {
            DataTable dt = new DataTable();
            dt.Load(myReader);
            int count = dt.Rows.Count;
            JournalEntryTotal.Text = count.ToString();
        }
    }

I am trying to make a call from views to controller using jquery. however it never call controller.

I have a Umbraco 7.1.2 website in asp.net MVC 4 application.

My JS

var dp = jQuery;
dp.noConflict();
dp(document).ready(function() {
    GetTestimonials();
});

function GetTestimonials() {
   dp.ajax({
        type: 'GET',
        url: '/Home/GetTestimonialsList',
        cache: false,
        success: function (data) {
            dp.each(data, function (index, val) {
                alert(val.Name + val.Comment + val.Date);
            });
        },
        error: function () {
            alert("error");
        }
    });
}

Then my controller

[HttpGet]
public JsonResult GetTestimonialsList()
{
     var model = _spdb.TestimonialDetails.Where(t => t.Status == Enums.TestimonialsStatus.approved).Select(t => new { t.Comment, t.Name, t.Date});
     return Json(model, JsonRequestBehavior.AllowGet);
}

I put a breakpoint on the controller, it never got called.

On the browser, no errors were raised with jquery.

However it always triggers alert("error"); when page loads.

I called console.log("test"); it displays on the browser debug.

On same page I am making a form post to controller using jquery and it has no problem at all.

the query from db gives me the data right.

What am I doing wrong?

Thanks a lot

I'm trying to call a controller method which returns a partial view. However the view returns with a null reference due to it being called without the controller.

How would I do it if I want to call the partial view throu the controller method.

So far my code looks like this:

Layout.cshtml

<div class="container" id="menu">
     @Html.Partial("~/Views/Category/_Menu.cshtml")
</div>


CategoryController.cs

public ActionResult Menu()
    {
        var model = new CategoryModel()
        {
            categories = new SortedDictionary<int, List<CategoryDTO>>()
        };

        model.categories[0] = new List<CategoryDTO>();
        model.categories[0].Add(new CategoryDTO()
        {
            id = 1,
            name = "Nålebinding"
        });
        model.categories[0].Add(new CategoryDTO()
        {
            id = 2,
            name = "Strik"
        });
        model.categories[0].Add(new CategoryDTO()
        {
            id = 3,
            name = "Hækling"
        });

        model.categories[1] = new List<CategoryDTO>();
        model.categories[1].Add(new CategoryDTO()
        {
            id = 4,
            name = "Sokker"
        });
        model.categories[1].Add(new CategoryDTO()
        {
            id = 5,
            name = "Vanter"
        });

        model.categories[2] = new List<CategoryDTO>();
        model.categories[2].Add(new CategoryDTO()
        {
            id = 6,
            name = "Sokker"
        });

        return PartialView("_Menu", model);
    }


_Menu.cshtml

@model GUI.Models.CategoryModel
@using DTO;

@helper subCategories(SortedDictionary<int, List<CategoryDTO>> list, int parent)
{
<ul>
    @foreach(var e in list[parent])
    {
        <li>
            @e.name

            @subCategories(list, e.id)
        </li>
    }
</ul>
}

@subCategories(Model.categories, 0)

I have no idea at all about the 3D Visualization ,and i want to create an application ,the application idea depends totally on the 3D structure .

I'll do my best to clarify my question to avoid considering it vague .

The main goal of my application is the (navigation) part in 3D environment .I want to upload maps of a specific area and the application allow to guide the user to its destination.(real time 3d rendering).

The application should work on kiosk ,smart phones and on web.(multiple platforms).


The following video clarify what i want to do exactly :

3D wayfinder


Now I want to know a start point to begin without reinventing the wheel,if there are some frameworks should i learn about first?

I'm a.net developer(asp.net) and i begin to learn CMS (Joomla),so it 'll be great to find APIs or frameworks near to this area to achieve my goal as soon as possible.

I need find all controls inside iframe

for e.g below method finds all controls inside .aspx page

private void GetControlList<T>(ControlCollection controlCollection, List<T>  resultCollection)
where T : Control
{
    foreach (Control control in controlCollection)
    {
        //if (control.GetType() == typeof(T))
        if (control is T) // This is cleaner
            resultCollection.Add((T)control);

        if (control.HasControls())
            GetControlList(control.Controls, resultCollection);
    }
}

like above method i need for iframe .... So i tried below java script

function find() {
    var iframe = document.getElementById('frame');
    var innerDoc = (iframe.contentDocument) ? 
                 iframe.contentDocument : 
                 iframe.contentWindow.document;
    var dd = innerDoc.getElementById('label1').innerHTML;
}

But i need to pass control id ...

How can i do that?

Hello i have written following code for reseting password for user.when i click on submit button ,page gets refresh and password is not updated .can any one tell me whats wrong with this code?

following is the code

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

    <br />

    <br />
    <asp:Label ID="Label2" runat="server" Text="Repeat Password"></asp:Label>

    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    <br />

    <br />

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
    <br />

    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="Passwords must match"></asp:CompareValidator>
    <br />
    <br />

reset pasword.cs code

    MembershipUser u;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {

            if (Request.QueryString["useremail"] != null)
            {
                u = Membership.GetUser(Request.QueryString["useremail"].ToString());


            }
        }

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
              if (u !=null) {


            u=Membership.GetUser(User, false);
            string passwordAfterReset;
            passwordAfterReset = u.ResetPassword();
             String newpassword=TextBox1.Text;
             Boolean passwordchanged = u.ChangePassword(passwordAfterReset, newpassword);
             Membership.UpdateUser(u);

             Response.Redirect("Login.aspx");

} }

I have an application which has ASPX & MVC pages mixed is same project due to some reason. The old aspx pages used to automatically render name element in the html generated e.g.

<form id="frmMyForm" name="frmMyForm" method="post" action="SomeOtherpage.aspx">

For some reason, in the new application, when we migrated these aspx pages to run with MVC ones, the name property is missing and the html looks something like this

<form id="frmMyForm" method="post" action="SomeOtherpage.aspx">

Has someone observed this behaviour and nkow it's solution? I'd like to have the name property back as it's being used heavily in my application in javascripts and figuring out all the places is not going to be easy.

I have an application which has ASPX & MVC pages mixed is same project due to some reason. The old aspx pages used to automatically render name element in the html generated e.g.

<form id="frmMyForm" name="frmMyForm" method="post" action="SomeOtherpage.aspx">

For some reason, in the new application, when we migrated these aspx pages to run with MVC ones, the name property is missing and the html looks something like this

<form id="frmMyForm" method="post" action="SomeOtherpage.aspx">

Has someone observed this behaviour and nkow it's solution? I'd like to have the name property back as it's being used heavily in my application in javascripts and figuring out all the places is not going to be easy.

For a school work I'm trying to develop a kind of search on my News SQL table.

I get from a text box the search query (split by ;) and then I query the database comparing the user query in lowercase with the titulo, the descrição and the tags in lowercase. This runs fine until the second foreach, I'm not having success merging a list of IOrderedQueryables.

  String[] terms = TrabPratico1.Funcoes.splitString(tbTermos.Text, ';');
    List<IOrderedQueryable<Noticias>> listaResultados = new List<IOrderedQueryable<Noticias>>();
    foreach (String term in terms)
    {
        listaResultados.Add((from noticia in bent.Noticias where noticia.Titulo.ToLower().Equals(term.ToLower()) || noticia.Descricao.ToLower().Equals(term.ToLower()) || noticia.Tags.ToLower().Equals(term.ToLower()) select noticia).OrderByDescending(x => x.Data));
    }
    var resultado = Enumerable.Empty<Noticias>().AsQueryable<Noticias>();
    foreach (IOrderedQueryable<Noticias> iq in listaResultados)
    {
        Queryable.Concat(resultado,iq);
    }
    //lblResultados.Text = resultado.Count().ToString();
    lvResultados.DataSource = resultado;
    lvResultados.DataBind();

The bent variable is an Entity Framework class.

My code runs fine (does return the appropriate number of news) but I've been trying to join the list of IOrderedQueryable in order to put it on a ListView, however it always throws an exception that lvResultados must have a data source which implements ICollection or that proceeds to data source paging if AllowPaging is true (sorry roughly translated from Portuguese).

I'm doing concat inside of the second foreach, but I feel that it should be Union to remove duplicates.

I was used this Code for sum the Column value s

int total = 0;
protected void gvEmp_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType==DataControlRowType.DataRow)
{
total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Amount"));
}
if(e.Row.RowType==DataControlRowType.Footer)
{
Label lblamount = (Label)e.Row.FindControl("lblTotal");
lblamount.Text = total.ToString();
}
}

I'have more data's in my database . so i have decided to use Linq Query which is below

GridView1.Columns[8].FooterText = (from row in dt.AsEnumerable()
                                   select row.Field<int>("amount")).Sum().ToString(); 

but I have Paging in my Grid , Page size is 50 so i have to sum the 1 st page total at first If i Click to 2nd Page then i have to show the 2nd page total. how to achieve that ?

I'm encountering the exact issue as described here(EF: Cannot attach the file ‘{0}' as database '{1}'). My question is how to run these commands in Package Manager Console of Visual Studio 2010 SP1:

  • sqllocaldb.exe stop v11.0
  • sqllocaldb.exe delete v11.0
  • update-Database

All these commands perfectly run in Package Manager Console of VS 2012, but when I try to run these commands in VS 2010 SP1, then VS 2010 SP1 cannot recognize them.

What are alternative commands in Package Manager Console of VS 2010 SP1?

I am using MVC 4 and kendo UI for grid population. But the grid is not populating correctly.

this is my View :

<script type="text/javascript">

        $.ajax({
            url: '@Url.Action("Employee_Read", "UserSummary")',
            type: 'GET',
            dataType: "json",
            Async: true,
            success: function (data, textStatus, xhr) {
                var dataloc = data;



                var element = $("#grid4").kendoGrid({
                    dataSource: {
                        data: dataloc,
                        schema: {
                            model: {
                                fields: {
                                    userDetailsId: { type: "number", editable: false },
                                    name: { type: "string", editable: false },
                                    roleId: { type: "string", editable: false },
                                    emailId: { type: "string", editable: false }
                                }
                            }
                        }
                    }
                });
            }
        });
    </script>

Conroller ;

 [HttpGet]
    public ActionResult Employee_Read([DataSourceRequest]DataSourceRequest request)
    {
        using (var emp = new MockProjectAkarshEntities1())
        {
          IQueryable<tbl_UserDetails> userDetails = emp.tbl_UserDetails;


            DataSourceResult result = userDetails.ToDataSourceResult(request);

            return Json(result,JsonRequestBehavior.AllowGet);


        }

In the output I am getting something like "[object][object]" and no of rows in the table returned from database.the skeleton of grid is coming but not the data. I am new to MVC and kendo. Please help me out.

I am Creating News type Website in MVC (ASP.NET - C#)

There will be a homepage showing latest 10 news (example) and when you click on any one's title, it will be reload the page and show its description.

Now the thing is say for example....

1 News Article has title on top, then Paragraph 1 then 2 Images then 2 Paragraphs

Another News Article may have title on top, then 2 Paragraphs then 5 Images

So how to maintain this type of order, means it can be any order depending upon the uploader who is posting this news in its own login page....

All paragraphs and images to be stored in "Microsoft SQL Server 2012"

When i am trying to make change access modifier in controller it generate an error. If I make action method as non public then it will give a page not found error.

My database is called: Baseball and the table i want to display is called: Players.

I made a database that has different baseball teams and different players from baseball teams.

For example in my Teams table the team name "Red Sox" has a teamID '2' that primary key is linked to the Players table under "team". Now I have a few players with '2' as their team.

I created a html file and want to display only the Players with 2 as the data shown under team.

Here is the code I have so far I keep messing with it. I finally got this which gives me no errors however I don't know how to write a function that displays it.

@{  
    var db = Database.Open("Baseball");
    var selectQueryString = @"SELECT firstname , lastname  FROM Players WHERE team = 2";    
}