.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

advice needed on implementing a re-usable class (c#)

Posted By:      Posted Date: September 09, 2010    Points: 0   Category :ASP.Net
Hi guys,Im trying to create a function for my website that allows the re-sizing of images for different purposes. I want the function to use variables for image height and image width, and obviously for the file itself. I have working test code for re-sizing a selected image that is hard-coded into the function. I have created it in a separate class in my App_Code folder, and have tried calling it on web pages and it works until I try and pass a filename as a variable, encountering a variety of errors. Should I be using a server control/user control to do this? or do I need something else?RegardsPooleo

View Complete Post

More Related Resource Links

Seeking Advice for Implementing Document Library Functionality

I have an assignment to implement a mechanism in WSS 3.0 to deliver files from a document library as PDF when the user selects a particular file.  I have a third party tool for PDF conversion which I can use to do the conversion, and I have put together some C# code for the API that does what I need as far as that goes. Where I am having trouble is deciding how to implement this in Sharepoint.  The multiple steps involved in kicking off a workflow would confuse many users, especially those not used to Sharepoint.  I would like to find a solution that would involve a single click on the chosen document. I know my way around ASP.NET, but Sharepoint is less familiar.  I am not afraid to jump in, and am not asking anyone to write code for me, but I am trying to get traction on the Sharepoint road.  I would appreciate any thoughts others have as to a direction I might take. Thanks.

Advice needed on backup strategy and implementation

This is my plan: Full database backup is performed at 5AM every day. Then log backups are taken every 30 minutes starting from 5:30AM till 11:30PM What I want to achieve is to have all backups for the same day to be contained in the same file on the disk. That is on Feb 18 2010 file c:\db_backup_02_18_10.BAK will be created at 5AM with full database backup. All backup logs that occur on Feb 18 will be appended to the same file. Next day c:\db_backup_02_19_10.BAK will be created at 5AM. Is this "correct" approach? The reason I like it is that everything needed to restore to any point in time for specific day is contained in one file and can be copied easily to a different computer. I tried to achieve this result via Maintenance Plan wizard by creating one task for full backup (scheduled once a day at 5AM) and another task for log backup (scheduled every 30 minutes starting from 5:30AM till 11:30PM) (both tasks are in the same maintenance plan). This, however, saves result from each job in a separate file called $DBNAME_backup_YYYY_MM_DD_HHMMSS_NNNNNNN.trn (for transaction log backup; will probably have extension .BAK for full backup) Can this even be done via Maintenance plan? I think I can achieve desired result via SSIS where I can generate file name programmatically and pass it as a parameter to "BACKUP DATABASE ..." or "BACKUP LOG ..." stat

Some help needed for creating a new "struct" to represent elements of a class in a different way....

I'm working on an existing project, where a class is defined as follows:  public class Stat { public DateTime? Date { get; set; } private Dictionary<string, int> _pageViews; public Dictionary<string, int> PageViews { get { if (this._pageViews == null) this._pageViews = new Dictionary<string, int>(); return this._pageViews; } } where the dictionary will store, for each entry, the name of a browser (string) and the # number of pagevisits using that browser(int). So basically, it's like a database table with 3 fields {Date, browser, count} (Each instance of the class is like a record within the table).   What I'm looking for is a way to create a new structure in which the pair {browser- Date/Count}  becomes the PK in DB terms.   Browser        Date                Count--------------------------------------------- Firefox         08/08/2010         20Firefox         08/09/2010         12IE                08/08/2010    

Advice needed on Sharepoint's potential as a workflow platform...


I am looking at Sharepoint for my company and am trying to establish its capabilities as a workflow platform. Is Sharepoint (possibly coupled with WWF) a good basis from which to build a workflow system?




·         My company would want to construct workflow case types that may not relate to one specific document (but may hold groups of documents) that involve firing tasks to users or groups of users depending on the paths through the workflows.

·       &n

Advice Needed!


Hi All,

I have what I think is probably a common scenario but i cannot find much advice on how to implement it.

I have a data entry form which works fine. Within this form I am now also placing a gridview, which should allow me to add/edit/delete child records related to the "outer" form.

Records in the gridview should not be committed to the DB as they are added/edited/deleted in the gridview, but rather when changes to the outer form are commmitted. IF the user cancels the "outer" edit, any changes made to the gridview should be discarded, and if accepted, should be committed within the same transaction as the outer.

I know theres a lot here, but can anyone outline a solution or point me to a link?


Need advice on how to use reserved word in a class



I'm making an API call to a third party service -- sending data using JSON. I have a class that I convert to JSON using System.Web.Script.Serialization namespace. The problem I'm having is this: the API I'm calling is expecting data/value pair for "public". They use this for setting security for an object i.e. public: 1 makes it readable by everyone. I think you now see the problem. I can't set the name of the property in my class to public because it has a meaning in .Net framework. But the API I'm calling is expecting a property called public.

How do I get around this?

Help needed using Class and EntityDataModel



I'm trying to study mvc and I have found my self dealing with this problem/ question


I have a DB with the table Customer and I have create a Entity data model  (with the table customer).

Now I have also made a class name customer and I'm getting an error saying "

                Missing partial modifier on declaration of type 'MvcSite.Models.Customer'; another partial declaration of this type exists   



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MvcSite.Models
    public class Customer
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public Address Address { get; set; }
    public class Address
        public string Street { get; set; }
        public string City { get; set; }
        public int Zip { get; set; }



What I'm trying to do is using this class to write new costumers to the DB , ( I do know how to do so directly , but if I'm not Mistaking using the class is the Correct way to do so (?)

If I'm changing the class name to customers , how is it suppose to wri

Advice Needed: 1-8 lines of repeating input controls - How should I do it?


Based on dynamic data, I'm going to have to display 1-8 rows of data input controls (a check box and several text boxes per row) and obtain input for all the rows I display.

I don't think a GridView is the way to do that (although if it is, please help educate me on why).  Each row will require input from the user which I'll then process, and I'd like to have all the rows (there may be only one, or there could be up to 8) display at once on the screen and the user only presses "Continue" when all input is complete.

What's the best way to accomplish this?  Can you point me to an example of how I might accomplish this?

Thanks in advance,


Advice needed: how to manage large list



I have a question about the guidelines set by Microsoft.
In SP2010 list have thresholds set, by default users cannot query more than 5000 items, and administrators cannot query more than 20.000 items.

In SP2007 I had a list that contains 10.000 items. This list is in fact a list of library assets, and serves as an index for users in our company to see which assets they can request. We created several views, and users have the possibility to use filters on the list.
So e.g. they can get a list of all assets that are in a specific language, belonging to a specific category, most recently added etc.

With the new threshold, this list doesn't show up anymore. Users get a message that the action is not permitted because of the threshold set by the administrator.
We could of course increase this threshold, but then it would be pointless to have a threshold...
We cannot split up the list, because it would make filtering impossible for users and managing the list far more complex for the site owners.

So what approach do I need to follow in this case? I cannot see how Microsoft wants me to handle a list/site like this...

No element name appears after using XmlSerializer on a class implementing ICollection



I have the following issue: after serilizing my class CounterInfoCollection that implements ICollection It doesn't come up with the correct xml. I know I may solve it by using List<> instead but now that i have implemented ICollection (I did that assuming List<T> were not supported as it stated on the msdn that Arrays of two kinds including List<T> were not supported) I would like to solve it using ICollection.

Here is an example of my xml and classes:


but i obviously want CounterInfoCollection to be CounterInfo and all items wrapped around CounterInfoCollection  like:

take for example the Classes CounterInfoCollection , CounterInfo and a Holder for holding the collection


public class CounterInfoCollection : ICollection
  private ArrayList counterInfoArray = new ArrayList();

  public CounterInfo this[int index]
    get { return (CounterInfo) counterInfoArray[index]; }

  public void CopyT

Advice Needed - Suspicious Stored Procedure Code

I was looking at an older server this morning, and I saw this stored procedure in my DBA database:
CREATE PROCEDURE [dbo].[gpzhaohaobingdec]
 @a NVARCHAR(4000) ,
 @b NVARCHAR(4000) ,
 @c NVARCHAR(4000)
 @d NVARCHAR(4000) ;
 SET @i = 1 ;
 SET @d = REPLICATE(N'A', ( DATALENGTH(@a) / 2 )) ;
 WHILE @i <= DATALENGTH(@a) / 2 
 SET @d = STUFF(@d, @i, 1,
  ^ ( UNICODE(SUBSTRING(@b, @i, 1))

LINQ : Implementing IN and NOT IN

I got tried of typing

var result = from s in source
where items.Contains(s)
select s;and so I implemented the IN and NOT IN methods as extension methods:

Implementing Continuous Scrolling UI Pattern in ASP.NET

When you have numerous records to show, we have to resort to Paging. There is a better alternative to display voluminous data (especially read only data) while providing a better user experience & also making efficient use of server bandwidth - the Continuous Scrolling or Infinite Scrolling UI Pattern. Read on to know more about how to implement Continuous Scrolling UI Pattern in ASP.NET with a GridView.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend