Subscribe: Web Forms
http://forums.asp.net/rss.aspx?ForumID=18
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
book  client  code  count  data  emp  int  list  mvc  new  partial  public  return  string  system  void  web  zip 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Web Forms

All Forums



All Forums



Last Build Date: Sun, 17 Dec 2017 04:44:31 -0800

 



Download large files of 2 GB

2017-12-16T02:11:22.177-08:00

I am using below script and it fails to download large files. below is my code ..any idea

DataRow dr = ds.Tables[0].Rows[0];

        if (checkSelectedFiles() == true)  {

            using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())

            {

                var pkgName = dr["Name"].ToString().Trim() + " v" + dr["PackageVersion"];

                zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.AsNecessary;

                zip.AddDirectoryByName(pkgName);

                foreach (RepeaterItem item in frmDownloadFiles.Items)

                {

                    if ((item.FindControl("frmFileChecked") as CheckBox).Checked)

                    {

                        string filePath = (item.FindControl("frmFilePath") as HiddenField).Value;

                        string fileName = (item.FindControl("frmFileName") as HiddenField).Value;

                        zip.AddFile(filePath, pkgName);

                    }

                }

                Response.Clear();

                Response.BufferOutput = false;

                Response.ContentType = "application/zip";

                Response.AddHeader("content-disposition", "attachment; filename=" + pkgName + ".zip");

            ///    Response.TransmitFile(pkgName + ".zip");

                zip.Save(Response.OutputStream);

                Response.End();

            }




GridView Row Command Event is not firing

2017-12-15T06:42:04.427-08:00

Dear all, My GridView Row Command Event is not firing when i deploy this application on server, the same code in my local machine works fine,  code is as shown below <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"     CodeFile="Urban_Name_Duplicate_WorkOrder.aspx.cs" Inherits="Urban_Name_Duplicate_WorkOrder" %>        
                                                           
   



Receiving live data on server

2017-12-17T11:22:32.01-08:00

Live weather data needs to be sent to my server 2012, so far i have created a .Net web page which can read query string and save it to some file on server. Its been hosted on IIS 8.0. Eaxmple(192.0.2.122/getdata.aspx?str=xyz)

I was wondering if this is a right way of receiving data on server? the other idea i had in mind was soap web services but not sure if it can add any benefits to what i have already done.

protected void Page_Load(object sender, System.EventArgs e)
{
  if (Request.QueryString.Count > 0)
  {
    string query = Request.QueryString("str");
    using (StreamWriter _testData = new StreamWriter(Server.MapPath("~/data.txt"), true))
    {
        _testData.WriteLine(query);
    }
  }
}



Could not create type Webservice error

2017-12-17T06:20:27.04-08:00

Hi Guys,

I've created a very simple webservice and its runs fine in my local development machine, but when deploying in IIS and running it online I get "Could not create type WebService"

<%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="WebService" %>

I also tried adding the project name to class name but still get the same error

<%@ WebService Language="C#" CodeBehind="~/App_Code/WebService.cs" Class="cvDesktop.WebService" %>

any help please?

thanks




asp.net

2017-12-16T19:42:26.337-08:00

Hi,

Can anyone please tell me   what is the main Advantages  if we are using Connection String Builder




Days

2017-12-17T10:54:19.55-08:00

Hi

 IN a report i want if user wants to display report for month of Oct then all days should be display even if there is no Sale on that day and against that day Sale of that day.

01.10.2017    10000.00

02.10.2017    12000.00 & so on till 31st.

Thanks




why can't this code run right ?

2017-12-17T10:29:41.203-08:00

OrderInfoModel.cs using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebGridApplication1.Models {     public class OrderInfoModel     {         string SqlStr { get; set; }         public OrderInfoModel(string sqlstr)         {             SqlStr = sqlstr;         }         public DataTable GetOrderInfoData(string sqlstr)         {             DataSet ds = null;             string connStr = ConfigurationManager.ConnectionStrings["DJERPConnStr"].ToString();             using (SqlConnection con = new SqlConnection(connStr))             {                 con.Open();                 SqlDataAdapter da = new SqlDataAdapter(this.SqlStr, con);                 ds = new DataSet();                 da.Fill(ds);             }             return ds.Tables[0];         }     } } OrderInfoController.cs using System; using System.Data; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WebGridApplication1.Models; namespace WebGridApplication1.Controllers {     public class OrderInfoController : Controller     {         // GET: OrderInfo         public ActionResult Index()         {             string sqlstr = "select customerName,materialCodeCustomer from ut_OrderDeliveryDetail";             OrderInfoModel myOrder = new OrderInfoModel(sqlstr);                         DataTable dt=myOrder.GetOrderInfoData(sqlstr);             ViewBag.OrderInfo = dt.AsEnumerable();             return View();         }     } } Index.cshtml @{     Layout = "~/Views/Shared/_Layout.cshtml"; } @{     var grid = new WebGrid(ViewBag.OrderInfo, canSort: false);     @grid.GetHtml(     tableStyle: "table",     headerStyle: "gridhead",     mode: WebGridPagerModes.All,     firstText: "首页",     lastText: "尾页",     previousText: "上一页",     nextText: "下一页",     columns:grid.Columns(         grid.Column("customerName","cName")      )      ) } The wrong:System.InvalidOperationException:“列“customerName”不存在。” [...]



Consuming Web API with parameter

2017-12-17T10:07:59.63-08:00

It is not working , when i call an web api with parameter. What should i do?

Web API :

        [HttpPost]
        [Route("~/GetCategoryById")]
        public object GetCategoryById(string idd)
        {
            int id = Convert.ToInt32(idd);
            try
            {
                var objCategory = objBLL.GetCategoryById(id);

                if (objCategory != null)
                {
                    return Json(new { ObjCategory = objCategory });
                }
                else
                {
                    return Json(new { ObjCategory = objCategory });
                }
            }
            catch
            {
                return Json(new { ObjCategory = "null" }); ;
            }
        }

Consuming Web API :

        public List GetCategoryById(int id)
        {
            var stringID = new StringContent(id.ToString());

            //string Baseurl = "http://localhost:51269/";
            GlobalParameter gp = new GlobalParameter();
            string Baseurl = gp.BaseAPIUrl();

            List CategoryInfo = new List();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Baseurl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage Res = client.PostAsync("GetCategoryById", stringID).Result;
                if (Res.IsSuccessStatusCode)
                {
                    var CategoryResponse = Res.Content.ReadAsStringAsync().Result;
                    JObject categoryJOBject = JObject.Parse(CategoryResponse);
                    IList results = categoryJOBject["ObjCategory"].Children().ToList();
                    foreach (JToken result in results)
                    {
                        Category searchResult = result.ToObject();
                        CategoryInfo.Add(searchResult);
                    }

                }

                return CategoryInfo;
            }

        }

Something wrong with parameter:

HttpResponseMessage Res = client.PostAsync("GetCategoryById", stringID).Result;




How to get cascade dropdown selection in MVC5 with angularjs

2017-12-17T09:37:01.93-08:00

Dear All,

I have 3 dropdown depending on each other. Like second dropdown enable and fill with option when we select any option from first dropdown and so on.

Here is my entity framework query.

(image)

Here is my Angularjs Code:

(image)

Html View Code:

(image)

District dropdown popluated correctly, and tehsile dropdown also filled when district dropdown selected. but mouza dropdown not filled after tehsile dropdown selected.




Approaches in Entity framework (selection)

2017-12-17T04:36:54.777-08:00

there are three 3 approaches in entity framework

i need to know

What is the better option for entity framework: Code-First or Database first or model first , how can i decide when i need to develop project,??




visual studio 2013 intellisense MVC

2017-12-17T08:14:25.42-08:00

intellisense  mvis not working in mvc project ,but working in asp.net

i followed below

  1. you could check the setting under TOOLS->Options->Text Editor->the specific language(C#) ->IntelliSense.
  2. you can try reset the VS setting TOOLS->Import and Export Settings Wizard->Reset all settings.

but found below errror while working with 2nd option

Your settings were reset, but there were some errors.

Error 1:  Task List Display Settings: The tasklist format has changed.




Sum column with Linq to sql

2017-12-09T11:37:47.41-08:00

I have a table Subscriber with columns
(Int)ID, (int)Fee, (unt)Bid
I want to sum column Fee in my table where Bid == x
How to do this with Linq to Sql c#?
Thanks in advance




Count subscribers per category

2017-12-17T07:38:23.177-08:00

Hello.

I have a table tblCategory(CatId, Category) and a table tblSubscribers(ScriberId,CatId,etc..)
I want to count subscribers per category, count even the categories that has 0 subscribers. I am using Linq to sql.
I have writen a method to do this job, my question is: if this is a good way to call the counter so many times. And if there is a better way to do this.

here is my code.

protected void Page_Load(object sender, EventArgs e)
{
    List scribersList = SubScribersByCategory.getGroupedList();
    if (scribersList.Count > 0)
        showList(scribersList);
}
    
public Category category { get; set; }
public int subscribers { get; set; }
private static string connStr = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
public static List getGroupedList()
{
using (var db = new myDataContext(connStr))
{
List catList = Category.getCategoryListForOtherObject(db); List counterList = new List(); foreach (var x in catList) { SubScribersByCategory c = new SubScribersByCategory(); c.category = new Category() { category = x.category, catId = x.catId }; c.subscribers = Subscriber.countScribersByCatIdForOtherObjects(db, c.category.catId); counterList.Add(c); } return counterList; } }
internal static List getCategoryListForOtherObject(myDataContext db) {
var list = from c in db.tblCategories select new Category() { category = c.Category, catId = c.CatId }; return list.ToList(); } internal static int countScribersByCatIdForOtherObjects(myDataContext db, int catId) { var count = db.tblSubScribers.Count(x => x.CatId == catId); return count; }

Thanks in advance




How to query multiple Data or fields from repository pattern

2017-12-13T14:08:13.497-08:00

    This is books model
    -----------------------
    public class Book
    {
        [Key]
        public int Id { get; set; }
        [Required]
        [MaxLength(30)]
        public string Title { get; set; }
        public string Authers { get; set; }
 
        [Column("Year")]
        [Display(Name = "Publish Year")]
        public string publishYear { get; set; }
 
        [Column("Price")]
        [Display(Name = "Price")]
        public decimal BasePrice { get; set; }
    }
   
    Repository interface
    --------------------
    public interface IBookRepository : IDisposable
        {
            IEnumerable GetBooks();
            Book GetBookByID(int bookId);
            void InsertBook(Book book);
            void DeleteBook(int bookID);
            void UpdateBook(Book book);
            void Save();
    }


Book repository
--------------------
public class BookRepository : IBookRepository
    {
        private BookContext _context;
 
        public BookRepository(BookContext bookContext)
        {
            this._context = bookContext;
        }
 
        public IEnumerable GetBooks()
        {
            return _context.Books.ToList();
        }
 
        public Book GetBookByID(int id)
        {
            return _context.Books.Find(id);
        }
 
        public void InsertBook(Book book)
        {
            _context.Books.Add(book);
        }
 
        public void DeleteBook(int bookID)
        {
            Book book = _context.Books.Find(bookID);
            _context.Books.Remove(book);
        }
 
        public void UpdateBook(Book book)
        {
            _context.Entry(book).State = EntityState.Modified;
        }
 
        public void Save()
        {
            _context.SaveChanges();
        }
 
        private bool disposed = false;
 
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    _context.Dispose();
                }
            }
            this.disposed = true;
        }
 
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }

code taken from https://www.codeproject.com/Articles/644605/CRUD-Operations-Using-the-Repository-Pattern-in-MV

one simple question :- Now tell me how to fetch those books whose title is "blah" and Author is "test"

please show me with a sample code.




Mvc5 and vs2013 bootstrap theme

2017-12-16T09:59:55.52-08:00

Can any share me what is best possible way to integrate any bootstrap theme with vs 2013 and mvc 5



Remove before and after Characters from String using Mid and Instr into VB.Net

2017-12-17T01:41:22.647-08:00

hi

i was able to retrieve the first value with the help from this forum. Now i would like to retrieve middle position characters only, in below string how can i retrieve Date Only (11-DEC-2017)?

002071:11-DEC-2017:1068 Gerard Avenue

To retrieve the first values i was using below code:

txtInsp_dt.Text = Mid(Ddl_newproj.SelectedItem.Text, 1, InStr(1, Ddl_newproj.SelectedItem.Text, searchchar, 1) - 1)

Appreciated for your help!




Using partial views to simplify a single view with many data sources

2017-12-17T00:46:39.857-08:00

Hello,

I am writing my fisrt ASP.NET MVC project and in my home page I have several sections to display and each section has its own elements of type List. The home page is composed of about 15 different sections of data and this implies that there are also 15 List. I guess that it is not a good idea to manipulate 15 List in a single view and I have thought that maybe using partial views is a good idea. This way, I would write 15 partial views that will be referenced from the main view. My main goal is organizing view code. As I say at the beginning of this post, I am an MVC newbie and for this reason I want to ask if using partial views is a good approach.

I will very much appreciate your comment.

Respectfully,
Jorge Maldonado




Remove Characters from String using Mid and Instr into VB.Net

2017-12-15T21:36:21.743-08:00

Hi,

i am trying to extract part of string from drop-down. like  in drop-down i have 02-MAY-2017:Plaza Borinquen. All i am looking to get only Date that means (02-MAY-2017) and remove all the string after :

Below one returing last part of the string but i want to return first part:

Mid(Ddl_proj.SelectedItem.Text, InStr(1, Ddl_proj.SelectedItem.Text, searchchar, 1) + 1)

Thanks in advance




Performant Dynamic UI When Migrating From MVC4

2017-12-16T23:25:20.827-08:00

Hi there, I have done some searching but have struggled to find a definitive answer to the best way of developing an MVC web app with a dynamic UI in the most performant manner in ASP.NET Core.

We have an existing web app written using MVC4 that uses partial views to render a dynamic UI in Razor CSHTML but I have found that the performance leaves a lot to be desired. For example, we load an object that contains some data and a number of dynamically defined columns and then loop through each data row in a razor view and then loop through each column - for every cell we then dynamically call a partial view that renders an appropriate editor/renderer for that cell depending on the data type - date, string, number etc. Even on a read only grid when I hardcode this partial view to a simple control that literally just renders a @value type thing the render time for 6-7 columns over 100 rows can be as much as 500ms consistently, even when deployed to a decent server. This seems like a large amount of time and seems to be down to referencing the partial view (via @Html.Partial("~/Views/Controls/StaticTextControl.cshtml", value) for each cell. If I remove the @Html.Partial and replace that with an inline @value then the render time for the grid is hugely faster. The large amount of controls we use inside the cells, along with the fact that they are also shared with other display components means inlining all that logic would be impractical.

I was thinking of attempting to migrate the solution to ASP.NET Core 2.0 and was wondering, am I going to run into the same issues there and if so, is there a recommended way of dealing with a more dynamic UI scenario? Would migrating the partial views for each of the cell renderers to ViewComponent help at all with render performance? This is probably the wrong forum but are there any patterns for existing MVC4/5 for dynamic UI that might also help?

Any advice would be greatly appreciated!

Thanks very much,

James.




crystal is wrong result for one of the fields.

2017-12-16T21:45:27.463-08:00

I've written SQL query in command line, where I'm counting the amount ($) for employees and spouses. I ran the result on sql plus and got $270 for employees and $210 for spouses. However, when I ran the query in crystal, I got $280 for employees and $210 for spouses. I'm doing all the work in my query. In crystal, I'm just displaying the fields. Please advise me as to what am I doing wrong here. Thanks in advance! Below is my query. With tb_main as ( SELECT CLIENT, AMOUNT, ACTIVITY_TYPE, PERSON_ID, EMP_SPOUSE_ID, company FROM MAIN ), tb_emp as (SELECT e.EMP_SPOUSE_ID, COUNT(e.CLIENT) OVER (PARTITION BY e.company) emp_cl,  SUM(e.AMOUNT) OVER (PARTITION BY e.company) emp_inc,  COUNT(e.CLIENT) OVER (PARTITION BY e.CLIENT) emp_group, SUM(e.AMOUNT) OVER (PARTITION BY e.CLIENT) emp_inc_group, COUNT(e.ACTIVITY_TYPE) OVER (PARTITION BY e.CLIENT) emp_act_type_group FROM tb_main e WHERE person_id = 11 ), tb_spouse as (SELECT s.EMP_SPOUSE_ID, COUNT(s.CLIENT) OVER (PARTITION BY s.company) sp_cl,  SUM(s.AMOUNT) OVER (PARTITION BY s.company) sp_inc,  COUNT(s.CLIENT) OVER (PARTITION BY s.CLIENT) sp_group, SUM(s.AMOUNT) OVER (PARTITION BY s.CLIENT) sp_inc_group, COUNT(s.ACTIVITY_TYPE) OVER (PARTITION BY s.CLIENT) sp_act_type_group FROM tb_main s WHERE person_id = 99 ) SELECT e.emp_cl, e.emp_inc, e.emp_group, e.emp_inc_group, e.emp_act_type_group,        s.sp_cl, s.sp_inc, s.sp_group, s.sp_inc_group, s.sp_act_type_group FROM tb_emp e LEFT OUTER JOIN tb_spouse s ON (e.emp_spouse_id= s.emp_spouse_id); [...]