.net - Would Simple Class Instantiation Ever Fail In C#?

Jul 19, 2010

I saw some code written by another developer that looks something like this:

var stringBuilder = new StringBuilder();
if(stringBuilder == null)
{
// Log memory allocation error
// ...
return;
}

View 5 Replies


Similar Messages:

Web Forms :: 1.1 - Simple Class Doesn't Work

Mar 19, 2011

Why the following code (asp.net 1.1) does not work?

//call.aspx
<script runat="server">
namespace DOTNETMath {
void Page_Load( Object s, EventArgs e )
{
ConstClass.DisplayEmployee("Testing");
}
}
</script>
//commonFunction.cs
namespace DOTNETMath {
Public Class ConstClass {
Public Shared Function DisplayEmployee(String x) {
Return x + " Hello ";
}
}
}

View 14 Replies

Web Forms :: Implement Simple Spell Checking Class In C#?

Feb 22, 2011

I am using a rich textbox in my website, i need to check the spelling in the content of richtextbox. That i need to implement the spell checking class to check the spelling. give me the idea or sample code to achieve this.

View 1 Replies

Location Of HtmlHelper Instantiation For MVC?

Jan 3, 2010

I am trying to debug a problem where HtmlHelper is null in extension methods. Oddly the debugger claims it's fully populated, however I consistently get null exceptions. I'm trying to figure out where HtmlHelper should being instantiated in an attempt to see where my problem may be.

Where should HtmlHelper be Instantiated?

Update: In particular I am trying to implement the extension found here, [URL] within a masterpage. The error occurs on the MVC template's HomeController.Index(). There are some 'plugins'/virtualpathing that may be causing the problem (trying to avoid this can of worms), but, code the code is essentially the same as found here: [URL]. However, I don't want to trouble anyone with the details of all of that.

View 2 Replies

Web Forms :: Create A Simple Class Based One Tier Architecture

Mar 20, 2014

I am beginner in asp.net / vb.net and I developed a web application for inventory management. here I have my insertion procedure that I entered in my code behind all the different page of my application. My problem is the following:

* I would like to put my procedure in a class that I will call on my different page * how to create this class * how to call this class on my pages

here is my procedure:

Private Sub reqinsertion (ByVal sreq As String)
         Dim con As New System.Data.Odbc.OdbcConnection ("Dsn = dshealthboard")
         Sun ocommand As System.Data.Odbc.OdbcCommand
         con.Open ()
         ocommand = New System.Data.Odbc.OdbcCommand (sreq, con)
         ocommand.ExecuteNonQuery ()
         con.Close ()
     End Sub

View 1 Replies

Difference Between Object Declare Instantiation And Initialization

Oct 27, 2010

know what is object declaration and initialization but confused over ojbect instantiation ,i am giving a example below what i understood :

Class ABC
{
Public static Void main()
{
ABC a // Object declaration
a = new ABC(); //Object initialization
[code]...

View 2 Replies

Page Instantiation Faster If All Controls Are In The Markup Vs Defined In Oninit In Codebehind?

Jun 2, 2010

I was having a discussion with a co worker about some controls I implemented. He objected to my use of dynamicly instantiating controls in the code behind, because it will be slower than specifying the control in the markup. I thought he was talking about output cacheing which to my understanding only caches the rendered output of a page not the instantiated Page object. He said no its a different type of caching. Unfortunately he was unable to give me any documentation to backup the claim so I am wondering if anyone here has ever hear of any such type of caching, and if so is there any documentation on it that I can refer to.

View 5 Replies

Cant Get Class In App_Code To Work In Code Behind Page For Simple Page?

Jun 8, 2010

just a quick question -i cant get my class in App_Code to work in my code behind page for simple .net page, some light what doing wrong?

[Code]....

View 7 Replies

AJAX :: ModalPopupExtender Fail When Using SSL?

Jul 15, 2010

Am using ModalPopupExtender (In VS 2005 ). But it doesnot showing it when i use in SSL.

View 2 Replies

Certain PNG Images Fail To Load?

Sep 24, 2010

Using the code such as found below, sometimes certain .PNG files will fail to load. While other images, nearly identical in size, never have any such problem. Build Action set to Resource. Why is that? Anybody figure it out? This is for a datagrid but I doubt the control has much to do with it. Probably certain .png files make Visual Studio 2008 choke because of some attribute set internally. But it's a mystery to me....anybody else notice this? # private void dGrid_LoadingRow(object sender, DataGridRowEventArgs e) { Employee emp = e.Row.DataContext as Employee; FrameworkElement ele = dGrid.Columns[4].GetCellContent(e.Row); string url ="http://localhost:7642/DisplayImageHandler.ashx?id=" + emp.ID; Uri imageUri = new Uri(url, UriKind.RelativeOrAbsolute); (ele as Image).Source = new BitmapImage(imageUri); } private void img1_ImageFailed(object sender, ExceptionRoutedEventArgs e) { Image img = sender as Image; // Display an image for error here }

View 2 Replies

AJAX :: UseHttpGet Causes PageMethod To Fail?

May 30, 2010

I have a PageMethod that works perfectly well when it either (a) running in the VS dev server, or (b) deployed but marked with UseHttpGet=false.

What doesn't work, and is driving me mad, is having UseHttpGet=true and then deploying it to a test server (Vista & IIS7). It fails to call through the proxy with error code 404 coming back. But it works find if I set UseHttpGet=false.

I have gone through all of the basic stuff I can think to check, and as noted it works perfectly well on the dev box. So there must be something particular about full-blown IIS7 and its config that I am missing..

anything to check in the IIS manager that would cause this to fail? I've tried with forms authentication enabled and disabled, as a few posts mentioned issues with that.

View 1 Replies

ADO.NET :: Trying To Update Entities Childs Fail?

Dec 20, 2010

I am working on my first project with Linq to Sql entities/winforms, and I have little problems updating the entities childs in the main form, when I come back from the entity editor....

I have a list of people, and I can edit them or add new. The edited or new person opens in a new form and can have many addresses that can be added modified from the person editor and it opens a third form...

when I have finished edit the new address, so i return to the person editor and add the address, within the person entity context... so person.address.add(newAddress)...

Then I update the list of addresses, referencing: Datasource= foreach(address adr in person.addresses).And when I have finished editing the person i return to the mainform and save the changes from that entity.

_datacontext.save()

The problems I have are that if there is a new person, and I don't add addresses, the person saves without problem. But It doesn't do it if I add any address. With the updates I haven't any problem, they updates all, adds new addresses, but I can't remove anything with the person.addresses.remove(address)...

View 3 Replies

MVC :: Login Fail After User Changes Password?

Mar 27, 2010

I have a problem when user changes the password using the Account Membership implementation from ASP.NET MVC.

I'm creating users from ASP.NET Configuration tool at Visual Studio. Thats works fine. But when my users changes password using the published site, the login process fail, when try to authenticate using new or old password, either.

Have any workaround that I'm forgot to implemento to avoid this?

View 6 Replies

Configuration :: Load Balancing Fail Over?

Nov 9, 2010

We are developing an ASP.NET eterprise level application. Customer wants to support for load balancing and fail over. Also customer need that if one server pc fails, end user should not notice that. is this possible? Will there be a timeout for the end user?

View 8 Replies

Installation :: IIS Website Fail To Start?

Dec 1, 2010

I have reasonable experience programming for windows form programs in VB 2005, but I am new in ASP.NET. I have tried the file system website, and it does not seems to have a problem for me. However, when I was trying to create a website to run with IIS, it failed. This is what happened, to start, I chose location:HTTP on the "new web site" dialog box, and using browse button, I opened the "choose location" dialogbox. I choose "Local IIS" on the lefthand side. Then, I create new virtual directory, with the alias name "Test" and folder c:my documentweb site st (new and empty directory). Then I clicked the open button, it was still fine, where it returned to the "new web site" dialog box. However, when I clicked the OK button on the "New Web Site" dialog box, it comes up with this error:

"Configuring web site 'http://localhost/Test' to ASP.NET 2.0 failed. You may need to manually configure this site for ASP.NET 2.0 in order for your site to run correctly"

When I clicked OK, it does come up with a blank website, however if I run it, it will comes up with this error:

"Unable to start debugging on the web server. The server does not support debugging of ASP.NET and ATL Server application. Click Help for more information on how to enable debugging" but there is no Help button!

By the way, all the trials are done in VB2005/ASP.NET 2.0, we are trying to upgrade to VB2010 sometimes next year. The computer is running Windows XP.

View 1 Replies

VS 2010 What Would Make Something Fail In IDE That Is Already In Production

Mar 7, 2013

What would make something fail in the IDE that is already in production?

I loaded just the aspx file into Visual Studio. it is just the file. It is used as a template on a CMS system (don't ask). The point is that I know that the paths work. So why does it fail in Visual Studio when I try to run it?

I have some asp.net code with a visual basic back end code file. It loads all the associated files located on the server that the aspx file mentions. But when I load the aspx file in Visual studio it says that a mentioned master page file cannot be loaded.

View 4 Replies

Error Report - Hard To Diagnose Because I Can't Get It To Fail

Apr 5, 2011

I've received 5 error reports from a site overnight.
XML Code:
Exception information:
Exception type: System.Data.SqlClient.SqlException

Exception message: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

It would seem that it's an issue with the server but it was reported to always occur at DomainModel.Services.ConfigService.get_companyName() which occurs when my config service asks the database for the company name using ByName("Company_Name")

Csharp Code:
private static Func<mvCmsContext, string, Configuration> _byName =
CompiledQuery.Compile((mvCmsContext context, string configName) =>

Is it just a server glitch or am I going to have to do some debugging today? I can't get it to fail no matter what I try.

edit - I just noticed one of the error reports was from a separate site. The first 4 were a local IP (ugh, probably the site owner) on one site between 11:00-11:04pm while the other was a chinese IP on my site at 11:07.

View 4 Replies

Security :: Fail To Log Out When Using Ajax For Adding Controls

Sep 30, 2010

My masterpage has a loginStatus control to let users log out and it works very well on normal pages .Recently, I created a new content page associated with the mentioned master page. Such new page allows users to add textboxes dynamically through ajax asycpostback.
Unfortunately, loginstatus right now fails to work when i click it. I traced the process and i found out that the loggingout event was not fired when i click it.

I follow this video to make such "Dynamically add control" page.

http://www.asp.net/ajax/videos/how-to-dynamically-add-controls-to-a-web-page

View 2 Replies

MVC :: Model Binding To Non-null Arrays Fail. Is This A Bug?

Mar 12, 2010

I have several models that implement a array property using null object pattern in the following manner:

[Code]....

The problem is that any time I attempt to bind to a property of this type the DefaultModelBinder.CollectionHelpers.ReplaceCollectionImpl method wants to call ICollection<T>.Clear() and then ICollection<T>.Add() on the zero length array.

The real issue seems to be in DefaultModelBinder.BindComplexModel() method however. The method contains an explicit check for arrays and special handling to account for the fact that they don't support clear/add functionality. The problem is that the check stipulates that the array model must also be null. If it is non-null, normal ICollection<T> handling ensues which presumes support for clear and add. Can any one explain why the null check is there? It seems to me that either 1) the null check should be removed to permit replacement based binding to non-null arrays or 2) an explicit error stating that non-null arrays are not supported should be thrown.

I vote for the former. I can understand that in general, replacing an existing model with a refrence to a different model would be considered a bad thing. The calling code would not expect this in general and it could lead to hard to find bugs. However, in the case of arrays, if the calling code expects the array property to be modified at all, then I think the normal expectation would be that such modification would occur via replacement of the array.

View 1 Replies

DataSource Controls :: SQL Server Authenticate Fail?

Jan 23, 2010

I want to login my SQL Server by using SQL Server Authenticate but this i fail to do thatI have already configurate "sa" account and change to "windows and sql server authenticate" still not workingCan someone tell me or show me the tutorial how to properly configurate to using "sa" to login by "SQL Server Authenticate"?

View 3 Replies

DataSource Controls :: Code Behind Fail SQL String?

Mar 16, 2010

ive an access database with a table, in this table there is only one data column and one counter column (id, pet) i want to draw random a record. Reading on the web i came with this SQL solution: "SELECT TOP 1 tab_pets.pet FROM tab_pets ORDER BY Rnd(id)" and it works perfectly.

The problem is while using this statement in my code behind (in a class) as it draw always the same record, hence generates the same random each time. I though that the access Rnd() function would be handled by the access driver and not by my application, how can i resolve this?

View 4 Replies

C# - StringValidator Always Fail For Custom Configuration Section?

Aug 27, 2010

I have created a custom configuration section in a c# class library by inheriting from ConfigurationSection. I reference the class library in my web application (also c#, ASP.NET), fill in the appropriate attributes and everything works great. The problem starts when I start adding validators.

For example, this property:

[ConfigurationProperty("appCode", IsRequired = true)]
public string ApplicationCode
{
get
{
return (string)base["appCode"];
}
set
{
base["appCode"] = value;
}
}

As is it works fine, but as soon as I add this:

[StringValidator(MinLength=1)]

It bombs with the following error:

The value for the property 'appCode' is not valid. The error is: The string must be at least 1 characters long.

I get this error even though a valid appCode value is in my web.config file. If I remove the validator it works perfectly.

View 2 Replies

IE Fail To Server CSV File From Response.Write?

Nov 9, 2010

I've recently developed a web user control that lists a series of reports. When the user clicks on the report it serves back a CSV file download in the response stream using the following code:

Response.Clear();

Response.ContentType = "text/CSV";
Response.CacheControl = "no-cache"; [code].....

The code initially worked fine in all browsers. Then the client put a requirement to use SSL for the site. As part of this I introduced a global handler to update the protocol from HTTP to HTTPS for all requests as follows:

protected void Application_BeginRequest(Object sender, EventArgs e)
{
string requestURL = Request.Url.ToString().ToLower();[code]....

However, since securing the site using SSL the CSV file downloads no longer work for IE although they do continue to work for Firefox / Chrome / Safari.

Is there something I am missing in the headers that is unique to IE in order for the file response to work correctly?

The message I receive from IE is:

"Internet Explorer cannot download
Reports.aspx from .... in ......

Internet Explorer was unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."

UPDATE:

Here is some example fiddler output coming back from the page request which looks like it's serving correctly. Why doesn't IE understand that it's just been served a file?

HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:23:50 GMT
Server: Microsoft-IIS/6.0[code].....

View 3 Replies

Implement A RequiredFieldValidator With A ValidationExpression Which Is Fail Validation?

Jun 8, 2010

I'm trying to implement a RequiredFieldValidator with a ValidationExpression which is fail validation if the value is -I'm guessing there will probably be a very simple RegEx for it but I am still trying to get my head around it.

View 7 Replies

Installation :: Installed VS2010, Apps Fail To Run?

Apr 30, 2010

I just upgraded to VS2010 and am having issues with my development machine. I have a number of MVC sites hosted on my local IIS (Windows 7, 64 bit). Before the installation of VS2010/.NET 4 everything ran fine. Now I'm getting errors of:HTTP Error 500.0 - Internal Server ErrorCalling LoadLibraryEx on ISAPI ilter "C:WindowsMicrosoft.NETFrameworkv4.0.30319aspnet_filter.dll" failedI have only found one other person with this problem and he had no resolution. Should .NET 4 be trying to load these sites?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved