ASP.NET is a web application framework developed by Microsoft to allow programmers to build dynamic web sites and web applications.

learn more… | top users | synonyms

1
vote
0answers
19 views

WebAPI - Return models vs entity and partial class with meta data

Wanted some opinions on something I have been working with, I've tried a few ways of structuring the way I retrieve and return data to my WebAPI, and I'm pretty happy with what I have so far, but I ...
2
votes
3answers
64 views

Generating and sending new password to user

Generate new password and send to user, if user is registered. Two TextBox on page, txtUserName & txtEamil. User can provide either UserName or Email to get new password. If UserName is provided ...
2
votes
1answer
34 views

Check if Item exists in Grid using Linq

I have a grid which allows a user to enter a new Grid item. If the grid item exists or the tb is empty it displays the error. Here's the code I came up with. Can anybody think of a cleaner or more ...
1
vote
1answer
65 views

Using static methods? [closed]

I am working on a ASP.NET web application and there was recently a need to dynamically generate columns. I created a static class ColumnBuilder.cs, which takes in an entity and returns an appropriate ...
1
vote
2answers
59 views

simple transaction process

I ask if the following code need some refactoring : public static int InsertBonus(DataTable dt, int month, int year) { int affectedRow = -1; using (IfxConnection con = new ...
2
votes
0answers
74 views

Acceptable Way to Navigate in ASP.NET MVC 4 in SPA-like App

I'm getting back into web development, and I'm creating a mobile-friendly web app. I'm trying to make it SPA-like in the sense that I don't load new pages for each action the user takes. As my ...
0
votes
1answer
18 views

Generalising the data binding operation

Can i create a method to do workks of these five section? I'm doing binding operation so many times. Have an idea to make these code more pretty? ddlModelValue -> asp.net DropDownList var ...
2
votes
1answer
135 views

When to use separate DBContext classes?

I know that the DBContext represents a session (Unit-Of-Work and Repository) with the database, however I an unsure as to when I should have a different DBContext. Currently, I have a separate ...
1
vote
0answers
64 views

Wrapping postback functions to call custom code at execution

Here is my solution for this stackoverflow question. It is designed to return an onbeforeunload message when the user leaves the page (excluding postbacks). It does this by logging a timestamp each ...
2
votes
1answer
78 views

Extract data from one column of SQL Server table

I have an SQL Server table from which I want to extract data from one column (DD) and return as multiple columns. The data is in NVARCHAR and looks like: ...
2
votes
1answer
95 views

Multiple Ajax Requests per MVC 4 View

I'm using the repository pattern with a context and ninject as the IOC. I have a service which handles getting and setting page properties in the database. public class MyContext : DbContext { ...
2
votes
0answers
72 views

optimize the pagination of repeater?

Hi I have some problem in my View.ascx.cs because I'm using reuse my code and modified it based on the situation for example I when I apply pagination I have efferent code in all place just I wan to ...
2
votes
2answers
218 views

Interface programming with Data Access Layer

I have several controls that are bound from database tables. Putting my OOP thinking cap on I figured since all of the controls will have a SqlCommand name and an associated SqlDataReader object I ...
3
votes
1answer
70 views

In need of some aid in regards to making my code more efficient

I've created a form that gathers and submits information to SQL database via LINQ, and sends an email if all goes while saving the database and doing a redirect. Recently, it started submitting data ...
0
votes
0answers
21 views

In need of some aid in regards to making my code my efficient [duplicate]

I have a form I have pulled together which gathers information and submits the information to SQL database via LINQ and sends and email if all goes well along with saving the database and doing a ...
0
votes
1answer
58 views

Searching for a better implementation to EnumBase

In a former question on SO I described a problem with a construct called 'EnumBase'. As I sad there, I am not involved when basic implementation happened. So I'm not sure why the thinks are a they ...
2
votes
0answers
259 views

Review my Generic ASP.net MVC controller that generates many pages?

I recently set out to create an open-source ASP.net MVC web development framework. Specifically, I wanted to automate some of the tasks associated with the creation of data-driven applications. I've ...
1
vote
1answer
65 views

How to optimize jQuery to run on asp.net web form updatepanel?

I wrote this Jqeury to make it work with asp.net update panel. I know i do little bit of hacking to make it work just. I want to get some help in how to optimize and remove the hacks from my script. ...
0
votes
1answer
52 views

What do you think of this coding style for web designers?

In my web development company, we have many designers who have the following development knowledge: Client-side web languages (HTML, CSS, JavaScript) Basic database design (how to create tables, ...
1
vote
2answers
133 views

Calling a button's OnClick method elsewhere - Good Practice?

I have two buttons on an ASP.NET page that have separate OnClick methods in the code behind. In one of the methods, if a certain condition is met, the entire process of the other method should be ...
2
votes
2answers
135 views

How can I make only one if-else statement among all of these?

I have these if-else statements that I am not able to refactor. I have used them for doing validations on server-side using asp.net. Would anyone please suggest ways to reduce these statements? ...
2
votes
1answer
147 views

Is there a faster way to get ASP.Net Validation messages in a Page or UserControl?

Edit: The method call discussed is a public extension method in a shared library. I'd like it to be safe for others to call. A little background: I'm maintaining an ancient system written in ...
1
vote
1answer
86 views

Which parts of my code are redundant?

Hey guys I have the following code, which i kind of just put together sloppily since I'm not really familiar with Razor/html... but nonetheless it does what I want it to do, which is basically passing ...
4
votes
1answer
134 views

Refactoring a method that binds data to a TreeView

All the flow depends on parameters. It's all in same method with an if else...but I want to make the code a bit more clear. How can I functionally decompose this method into many? private void ...
0
votes
1answer
38 views

Is this a good way to track current site being reported on?

I'm trying to find an elegant and secure way to track the currently reported site. I originally just used a cookie but realized this was not very secure. I have since switched to combine the session ...
2
votes
2answers
120 views

What Data Annotations need to be shared/different between my Model & ViewModel to keep seperation of concerns?

I read this question and answers, about if Display Annotations on model properties violates the separation of concerns between view and model. And my interpretation of their answer was "No, not if ...
1
vote
1answer
455 views

Better way to populate and save checkboxlist items to the database

I posted this question on stackoverflow and was instructed to post here. I have inherited an application that has code to save and populate values in a asp.net checkboxlist control. The existing code ...
2
votes
1answer
116 views

Using ViewState, start-to-end

I'm learning ASP.NET and think I figured out ViewState. Can you tell me if I have it right? The goal of the ViewState in this page is simply to keep the value in a DropDownList. So first, let's have ...
0
votes
1answer
412 views

How to optimize response.redirect in ASP.net [closed]

We know when we call HttpContext.Current.Response.Redirect("http://tvrowdy.in"); It throw an exception. Can we do it this way(working fine). Need suggestions and improvements. public static void ...
-2
votes
1answer
68 views

advanced asp.net improve performance [closed]

asked for help on my application , that's run on windows server 2003 and iis 6.0 ,this applications gross now , users now about 60,000 per day. and that what i did to make it faster a.SQL server 2005 ...
0
votes
2answers
373 views

Remove matched Rows from two Datatable (performance optimization)

Here I have two DataTables: dtTotalDateRangeExcludeSundays dtAbsentsLeavesHolidaysWorks Each having 10k+ values. I need to delete matched rows. Below code works fine foreach (DataRow rw in ...
1
vote
1answer
142 views

Asp.net MVC4, Lamba Sorting

I have the List method that takes sorting parameter to sort result. and the sorting parameter value is same to column name. And this is my code, public ActionResult List(string sorting = "Name", ...
1
vote
1answer
92 views

Making a property virtual to cause EF to load the property?

I am walking through a sample MVC4 ASP.Net tutorial available on PluralSight.com, by Scott Allen. I am in a section #5, Working with Data (part 2), "Listing Reviews". This application has a database ...
1
vote
1answer
63 views

XmlNodeList to ListItemCollection, a matter of elegance

at this moment I'm reading an XmlNodeList into a ListItemCollection one node at a time using a foreach. foreach (XmlNode node in authCompXml.SelectNodes("//Code")) { CompaniesList.Items.Add(new ...
2
votes
0answers
72 views

Models in .NET: separate settings?

For my models for a certain section I thought it would be better to have a base class model for both "view" and "edit" models, like so: public abstract class Setting { [Required] public int ...
2
votes
1answer
105 views

Is there a method to add multiple properties to HtmlTextWriterStyle?

I am creating new elements for a webpage at run-time and I have code like this: var dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("Div") {ID = "dynDiv"}; ...
0
votes
1answer
195 views

ASP.Net caching helper

I'm willing to simplify the use of the ASP.Net cache. I wrote this helper class : public static class CacheHelper { public static T GetCached<T>(string key, Func<T> initializer, ...
1
vote
0answers
84 views

Best practices in implementing service methods

Consider the following architecture: ASP.NET MVC Application having controllers which depend on service classes (MembershipService, EmailService etc.) which in turn depend on data access context ...
2
votes
3answers
957 views

Using Linq to select the first and last values

I want to get just the first and last values in a date range. I have the following code: using (var myEntities = new dataEntities()) { var myValues = (from values in myEntities.PointValues ...
2
votes
2answers
156 views

Building Session-Variables from a sql stored procedure

I have been advised to submit my code here by a fellow Stack contributer as it was suggested the code could be further improved; Calling Code and attempt at building session variables: DataTable ...
1
vote
2answers
135 views

MVC : Does code to save data is session or cache belongs in controller?

I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model? I would add that I have other controller methods ...
1
vote
2answers
168 views

Insert Selected item in listbox using Ado.net and stor proc

I create this class method to Enter Selected Items Form CheckboxList to associated resource I use ADO.net & store Proc to insert data can someone help me to improve it and make to so clean instead ...
1
vote
1answer
290 views

Truncate port number from absolute Uri

We had a requirement to remove the port number from the Request.Url.AbsoluteUr i.e Actual: https://mysitename:443/Home/Index Excepted: https://mysitename/Home/Index The code I used for ...
3
votes
0answers
472 views

Display progress bar to show async. request status using JQuery

Instead of using ProgressBar plugin, I've below script to display the progress bar for async. requests on the page. Could anyone provide any feedback on this esp. if there will be any issues like ...
1
vote
0answers
41 views

Sugestion on a better way to code this EF update?

I have a block of code that pulls the current menu position and compares it to what users selected, if the selection is different the database is updated with the new selection. As I am still new with ...
1
vote
2answers
234 views

MySQL GEAR, C# class for ASP.NET project

I've developed my own class in ASP.NET project to access MySQL and make queries, scalars and read the result from it. I want you to review my class and tell me where did I make a mistake, thanks! ...
2
votes
1answer
142 views

Cropping and combining two images on server

I've coded following two methods to combine images that are HTTP POSTed to the server: // Crops two squares out of two separate images // And then combines them into single image that's returned as ...
5
votes
2answers
946 views

Is there a better way to consume an ASP.NET Web API call in an MVC controller?

In a new project I am creating for my work I am creating a fairly large ASP.NET Web API. The api will be in a separate visual studio solution that also contains all of my business logic and database ...
1
vote
2answers
129 views

Is there a simpler way to write a row from one table to another?

I have the following code: const String sqlSelect = "SELECT * FROM UserPasswords WHERE username='System Administrator';"; const String sqlInsert = "INSERT INTO UserPasswords VALUES ...
3
votes
1answer
743 views

asp.net (vb.net): handling of open database connection and calling shared function from web api

I'm working on an ASP.NET project using VB.NET that uses Dapper and the code as implemented so far runs fine with just me testing. In the example below, Dapper calls a stored proc. But my I am ...