Declaring A Constructor Private Or Declaring A Class Sealed Is Same Thing?
Oct 12, 2010Is declaring a constructor private or declaring a class sealed is same thing?
View 1 RepliesIs declaring a constructor private or declaring a class sealed is same thing?
View 1 RepliesWhat is the use of declaring the static class. I know that we cant create the object for the static class but i want to know that is the use of creating the class as static.
View 1 RepliesI am looking for differences between those 3 ways of using static class in asp.net application scope.
Will all of these point to the same class?
Which one is preferable >object< defined declaratively inside global.asax or static class ?
examples:
<object runat="server" scope="application" class="classname" ID="objID"></object>
VS
public static class classname {}
VS
Application("a") = new classname();
Why is it that I cannot declare List in my web service using asp.net just like what I got on a certain site.
Code:
List<string> responses = new List<string>();
I just noticed that I can save a lot of spacing by not using "as" when declaring variables, in some cases (not sure if this is something new in VS2010). For example:
Dim Name as string = "Bob"
works the same as:
Dim Name = "Bob"
I prefer the latter as some of my type declarations can be very long due to the library I am working with, and omitting the types simplifies the lines and makes them more readable. I am wondering a few things:
1. Do the two methods function at all differently?
2. Is this a bad practice, or generally excepted?
3. Is there a name for this?
I just want to know the declaration of variables in a separate class file or declaring in the same aspx.cs file. the best practice of declaring the variables.
View 3 RepliesWhen the page loads, the GridView (located in an update panel) should be loaded with my first SQL SELECT statement. On the button click, the same GridView will be loaded with new data.
What am i doing wrong? On startup, the GridView doesn't appear.
Public cmd As New SqlCommand()
Public percentp As New SqlCommand()
Public da As New SqlDataAdapter(cmd)[code].....
public Jquery Extra(this HtmlHelper htmlhelper,
string message,
IDictionary<string, object> htmlAttributes)
if i declare the this Htmlhelper htmlhelper when i declare my method, but i don't want to pass that parameter in when i call the method?
I have a really simple web interface which has been created in visual studio 2010 and is connected to an SQL server running MS SQL Server 2008. I essentially want the user to be able to enter values into the two text boxes provided and when the button is clicked, these values are inserted into the relevant table in the database.
When I run the code, I get an error back saying that the 'scalar variable for @clientName is not defined.' I have altered the insert statement to fixed values rather than entering from the text boxes and this works fine (ie, replace @clientName and @serverName in the insert statement with 'xx' and 'yy' respectively). How I can define these scalar variables. I'm not to sure what i'm missing. Code below.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
[Code] .....
The code that the button executes is below
Partial Class Default2
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
SqlDataSource1.Insert()
End Sub
End Class
I want to declare a Dictionary<string, object> variable but don't know where/how to. The values in the dictionary will be objects from the Page (ListBoxes, DropDownLists, etc) so I can't exactly create a class somewhere else. Is there any way I can make this variable accessible from each method in the codebehind?
View 5 RepliesHow do you declare a dictionary called MyDic in the master page?
I want MyDic to hold lists of objects MyObj with a date as the key so that I can write something like this: "get the list for date 1/28/2011 from MyDic" or "put this list of MyObj from 1/28/2011 in MyDic".
I'd like to declare the dictionary in the master page so that I can access it in every page.
I got a simple SQL Connection which works fine under VS 2005, once I convert to VS 2008, is failed to work. I even re-build entire apps from scratch under VS 2008, yet it still failed.
Here's the code.
[Code]....
The code failed at this line:
objCon = New SqlConnection()
Error message being:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.
I want to create a control just like a Panel.
I want my control to accept some controls as childs without typing the template name, just like the Panel, as shown here:
<asp:Panel runat="server">
My content
<div>Content</div>
</asp:Panel>
I have controls with content inside without telling what is the ITemplate.
I basically want to convert this
<my:MyControl runat="server">
<ContentTemplate>
My content
<div>Content</div>
[Code]....
The above works with <Content></Content> tags inside the control, but without it doesn't work. And the attribute isn't doing anything at all (I guess). What's missing?
I have this procedure
[Code]....
I don't know what variable should be put in where clause for tblVisitor.visitorID because there's a variable that was already passed by an output identity parameter by a different stored procedure. What will I put in the where clause for visitor id?
I have a Interface for CRUD operations.and some classes implemented it.I want to design a user control that have two buttons:insert and delete,to reuse this control over my forms.this class must have a instance of my interface to do insert and delete tasks (if I'm right).this is my interface:
[Code]...
my problem is,i can't declare a property of type ISchoolSystemRepository in user control,because i must pass T for interface.
I have a legacy solution where all the DataSources are defined in the markup for all .aspx-pages. The problem I have with this is that the DataSource get instantiated several times since it is used in page, control... What I want is to have NInject to handle the instantiation of the DataSource so this doesn't happen. I have got that part to sort of work, but when the DataSource is defined in the code-behind instead of in the markup the Page property is not set on the DataSource, does anyone know why? A simple solution to this is to set the the Page property in a base class or something, but I do think that the property should be there and want to know why.
View 2 RepliesI am loading .aspx and .ascx files as StreamReader.
I want each file to register it's javascript and stylesheet dependencies in some declaration like a <%@ ClientDependency path="~/Scripts/jquery-1.4.1.min.js" %>.
Is there an existing convention for doing such a thing? I don't need an implementation, but I don't want to create a new syntax if there is already a way to do it.
Also, what are the guidelines for custom <%@ blocks in ASP.NET?
i have a dropdown list with values
America
Asia
Europe
I need to the display the ddl as Select Type and when i click the dropdownlist to see the values in it, it should display the three values, but i should not use Select Type as a list item and it should not be displayed in the list. It should only be used as a default text in ddl.
Declaring the SqlConnection and SqlCommand objects in a webform without CodeBehind I am trying to query data from a MS SQL server with a C# web form without "CodeBehind". I want to write the information to a table in the web form's body.
I am having trouble declaring the SqlConnection and SqlCommand objects that connect to the server.
How do you use "using System;", "using System.Data;", "using System.Data.SqlClient" inside the script element of an .ASPX file?
(code below)
[Code]....
I have been using .NET 2.0 and VS 2005 for web application project and lately i am noticing that .designer.aspx.cs does not declare all the controls 'automatically' which r there on .aspx...i add them manually and some of them get lost,like the additional 'div' controls which i have on pages inheritated from the master,everytime i reload it.. ..i fully understand that i am not suppose to manually change anything in designer.aspx.cs but what do i do with this issue? Is .net 2.0 ,VS 2005 are too obsolate and i absolutely need to get on .net 4.0,2010..
View 5 RepliesCan someone tell me the syntax to declare today's date in a stored procedure? I've searched around and can't come up with a clear answer.
I'm trying to declare today's date in the stored procedure and then compare it to a date in a database?
Is it as simple as the following or am i way off?
[Code]....
why I am getting the following error message with the following code:The Code:
Partial Class test2
Inherits System.Web.UI.Page
Const ICEVarUsername = User.Identity.Name
[code]...
I created user control. It exposes string[] public property (it may be List<string> or whatever). I want to support defining this property in aspx code, when declaring the instance of this usercontrol. Something like this:
[Code]....
[Code]....
if a class has a private constructor then it cant be instantiated. so, if i dont want my class to be instantiated and still use it, then i can make it static. what is the use of a private constructor? Also its used in singleton class, except that, is there any othe use ? (Note : The reason i am excuding the singleton case above is because I dont understand why do we need a singleton at all ? when there is a static class availble.
View 8 RepliesPossible Duplicate: Use of var keyword in C# Hi, I am pretty new in C#,I would like to know the best practices in declaring variables.I know it is possible to use VAR (explicit declaration) or the DataType when declaring a variable (implicit).
View 3 Replies