If you hava a javascript like this:
1 <script language="javascript" type="text/javascript">
2 window.status ='some text';
3 </script>
You will see firefox is not showing "some text" in the status bar. Too see your text you must enable it from "Advanced Javascript Settings" window.
Happy coding...
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Tags: .net, .net framework 2.0, .net framework 3.0, .net framework 3.5, .net framework 4.0, c#, vb.net, dotnet, console |
Categories: Programlama, SSS (FAQ), Tip
Posted by
okutbay on
13.11.2009 17:32 |
Yorumlar (0)
Clipboard is a windows object. If you want to use clipboard in your .NET framework console applications you must reference `System.Windows.Forms` and mark your main method with `STAThreadAttribute` attribute.
Then you can use this class's methods e.g. Clipboard.SetText("some text to store in the clipboard");
Happy coding.
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
You can add the <location> element with the
“inheritInChildApplications” attribute to the root web.config. This
attribute will prevent child applications inherit some specified
configuration from the root web.config.
The attribute must be placed in the <configuration> section of the web.config. It looks like this:
<location path="." inheritInChildApplications="false">
<system.web>
<!--
……
Your settings
-->
</system.web >
</location>
Referance:
SectionInformation.InheritInChildApplications Property
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
While we are coding we used to delete blank lines with 'Shift + Del'. Shift + Del shortcut is same as 'Ctrl + X'. And if you copy something to clipboard before cutting the blank lines, it will be replaced by the blank line.
You can change this behaviour with VS 2008 settings. Tools > Option > Text Editor > All Languages (or just for specific language) > Uncheck 'Apply Cut or Copy commands to blank lines when there is no selection'
Happy coding...
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
You can switch the bit field's value with single update statement by using exclusive or operator.
UPDATE AdminUsers
SET IsActive = IsActive ^ 1
WHERE Id = 42
Happy codding...
Referance: ^ (Bitwise Exclusive OR) (Transact-SQL)
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
When you are using the SiteMapPath control page Urls with the querystrings, pages don't show the control. Because url can't be matched with url in your Web.Sitemap file.
To handle this situation, a little web.sitemap file trick is enough. Write the static part of your Url and define the dynamic querystring parameters at "reliantOn" attribute.
Sample Web.sitemap node definiton:
1 <siteMapNode url="~/a.aspx?p=add" title="ABC" reliantOn="Id" />
Happy codings...
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
When you are developing application you may need to store timespan database. (Assuming you are using Sql Server 2005)
TimeSpan.TotalSeconds can be used to store. This returns a double. And maps to decimal data type of the sql server. For reverse action to get the time span you can use TimeSpan.FromSeconds method. This will give you the nearest millisecond value of the stored data.
But if you need accuracy you can use TimeSpan.Ticks method is suitable for you. This returns Int64 (long) and maps to bigint data type for to store in db.You can convert it to TimeSpan with the TimeSpan.FromTicks method.
"Using Ticks more accurate then FromSeconds"
Sample (.aspx page):
1 string startTime = "13:46:33.5268767";
2 string endTime = "13:47:03.1988761";
3 DateTime startDate = Convert.ToDateTime(startTime);
4 DateTime endDate = Convert.ToDateTime(endTime);
5
6 Response.Write(string.Format("Start Date : {0}<br/>", startDate));
7 Response.Write(string.Format("End Date : {0}<br/>", endDate));
8
9
10 TimeSpan timeSpan = endDate - startDate;
11 double timeSpanValue1 = timeSpan.TotalSeconds;
12 long timeSpanValue2 = timeSpan.Ticks;
13
14 Response.Write(string.Format("From Seconds : {0} (Rounded To Nearest Millisecond)<br/>",TimeSpan.FromSeconds(timeSpanValue1)));
15 Response.Write(string.Format("From Ticks : {0} (More Accurate)<br/>", TimeSpan.FromTicks(timeSpanValue2)));
Happy coding...
1 kişi tarafından 4.0 olarak değerlendirildi
- Currently 4/5 Stars.
- 1
- 2
- 3
- 4
- 5
For example you have a base class and a class that inherits it like below.
1 public class A
2 { }
3
4 public class B : A
5 { }
And you have generic list of these types. Then if you want to convert List<B> to List<A>
You can use this code block:
1 List<B> listB = new List<B>();
2 List<A> listA = listB.Cast<A>().ToList();
Happy coding.
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
In .NET world it's very common to write methods with same name but different parameters. This is called overloading. And if you use this technique wisely you can prevent some code repetation.
But in the web services world of .net its not allowed by default. If you try you get an exception says : "Bla, bla, bla. Use the MessageName property of the WebMethod custom attribute to specify unique message names for the methods."
Server Error in '/ICFWebServices' Application.
Both
ICFWebServices.Entities.Portal GetCategorizedRoomData(System.String)
and ICFWebServices.Entities.Portal GetCategorizedRoomData() use the
message name 'GetCategorizedRoomData'. Use the MessageName property of
the WebMethod custom attribute to specify unique message names for the
methods.
First you must differ your methods with WebMethod's properties.
1 [WebMethod(MessageName = "GetCategorizedRoomData",
2 Description = "Gets the room list for configured portal name")]
3 public Portal GetCategorizedRoomData()
4 {
5 string portal = "ICanFootball"; //Buraya web.configden portal okuma gelecek
6 return populateCategorizedRoomData(portal);
7 }
8
9 [WebMethod(MessageName = "GetCategorizedRoomDataByPortalName",
10 Description = "Gets the room list for given portal name")]
11 public Portal GetCategorizedRoomData(string Portal)
12 {
13 return populateCategorizedRoomData(Portal);
14 }
Second you have to change your web service class Wsi profile to none
1 [WebService(Namespace = "http://tempuri.org/")]
2 [WebServiceBinding(ConformsTo = WsiProfiles.None)]
3 public class RoomService : System.Web.Services.
WebService
4 {
If you forget step 2 you get an exception like
Server Error in '/ICFWebServices' Application.
Service
'ICFWebServices.RoomService' does not conform to WS-I Basic Profile
v1.1. Please examine each of the normative statement violations below.
To turn off conformance check set the ConformanceClaims property on
corresponding WebServiceBinding attribute to WsiClaims.None.
R2304:
Operation name overloading in a wsdl:portType is disallowed by the
Profile. A wsdl:portType in a DESCRIPTION MUST have operations with
distinct values for their name attributes. Note that this requirement
applies only to the wsdl:operations within a given wsdl:portType. A
wsdl:portType may have wsdl:operations with names that are the same as
those found in other wsdl:portTypes.
- Operation 'GetCategorizedRoomData' on portType 'RoomServiceSoap' from namespace 'http://tempuri.org/'.
To make service conformant please make sure that all web methods belonging to the same binding have unique names.
Happy coding.
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
We are developing a new ASP.NET web application in Visual studio 2008. Last week we've decided to use HttpHandlers instead of some web pages. And as we used to do in Visual Studio 2005 web sites created an App_code folder after that we created new classes under that folder.
Then we noticed that there is intellisense problem with these files. Also we noticed that there is a namespace problem with these classes.
When you add new class to app_code folder VS2008 names the class like this: RootNameSpace.App_Code.Class1. But object browser doesn't include any definition about App_Code namespace and sub classes.
figure 1: No namespace for ICFWeb.App_Code
Then I decided to check the properties of the classes. Right clicked a class under the App_code folder. And select its properties.
figure 2: No intellisense and color highlighting for editor.
When we looked at the properties. We saw build action for class is set to "Content". Problems are fixed after i changed that property to "Compile"
figure 3: Change build action from "Content" to "Compile"
After i searched the google for source of the problem. Problem is the app_code folder is for the web sites. There is no use of that folder for the web applications. Also app_code folder is not included in the "Add ASP.NET Folder" context menu of the solution explorer when you want to add App_code folder to your web application project.
Happy coding...
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5