C# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
C# etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

Visual Studio 2017'de Devexpress 17.2.5 Toolbox görünmüyor

Visual Studio 2017 Toolbox'ı üzerinde Developer Express componentlerini göremiyorsanız aşağıdaki komutu çalıştırmak işini görecektir. (Devexpress'i yeniden kurmanıza gerek kalmaz)

1. Visual Studio 2017'yi kapatın.
2. Yönetici olarak CMD (command) komutunu çalıştırın.
3. Sonra ToolboxCreator.exe'nin bulunduğu dizine
            cd\Program Files (x86)\DevExpress 17.2\Components\Tools 
   komutu ile geçin.
3. ToolboxCreator.exe /INI:toolboxcreator.ini  komutunu çalıştırarak işlemi tamamlayın.

 4. Sonuçta Toolbox üzerinde Devexpress componentleri gözükecektir.


Devexpress ASPxGridview "Value cannot be null. Parameter name : value" design hatası

1.       1. Tasarım aşamasında ASPXGridView nesnesi yerine “Value cannot be null. Parameter name : value” hatası karşımıza geldiğinde 2. adıma geçilir.

                    

2.      2. Projedeki aspx dosyasında hatalı olan Assembly dosyasının register satırı çıkarılmalıdır.  Find and Replace ile sorunlu olan <%@ Register namespace="DevExpress.Web" tagprefix="ASPxGridView" %>  satırı tüm projeden çıkarılır ve sorun giderilir.

k





C Sharp: İstenilen tarihin yılın kaçıncı haftası olduğunu gösteren metot


İstenilen tarihin yılın kaçıncı haftası olduğunu bulmak için aşağıdaki metot kullanılabilir. Framework içindeki Datetime sınıfında olmayan ancak işinize yarayabilecek bir metottur.


public int GetWeekNumber(DateTime dtPassed)
{
 CultureInfo ciCurr = CultureInfo.CurrentCulture;
 int weekNum = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek,      DayOfWeek.Monday);
 return weekNum;

}


Kullanımı:
int hafta = GetWeekNumber(DateTime.Now);  // 08.05.2014
//hafta= 19 olacaktır 



Devexpress AspxTextBox'ta veri girişi yaparken otomatik olarak büyük harfe çevirmek

Devexpress AspxTextBox'ta veri girişi yaparken, girilen bilgiyi otomatik olarak büyük harfe çevirmek için TextBox'ın Client-Side bölümünde  KeyUp  eventine

      s.SetText(s.GetText().toUpperCase());

yazılmalıdır.


ASP.NET formun otomatik yenilenmesi



ASP.NET'te bir form üzerinden yeni bir form açıldığında, geri dönüşte ilk formun yenilenmesi için 2. forma aşağıdaki kod eklenir.


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body onunload="javascript:window.opener.location.reload();">


Devexpress'te Sayı, Tarih, Alfanümerik format tabloları



Format Specifier
Description
Sample Format String
Sample Output
c or C
The number is converted to a string that represents a currency amount. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision from the current regional options is used.
c2
$1,234.00
e or E
The number is converted to a string of the form "-d.ddd...E+ddd" or "-d.ddd...e+ddd", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used. The case of the format specifier indicates whether to prefix the exponent with an 'E' or an 'e'. The exponent always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet this minimum if required.
E1
1.2E+003
n or N
The number is converted to a string of the form "-d,ddd,ddd.ddd...", where each 'd' indicates a digit (0-9). The string starts with a minus sign if the number is negative. Thousand separators are inserted between each group of three digits to the left of the decimal point. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision from the current regional options is used.
n0
1,234
x or X
The number is converted to a string of hexadecimal digits. The case of the format specifier indicates whether uppercase or lowercase characters are used for hexadecimal digits greater than 9. The precision specifier indicates the minimum number of digits in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. This format is supported for integral types only.
X8
000004D2

C Sharp, Formdaki tüm Texbox'ların içeriğini silmek


Formdaki tüm Texbox'ların içeriğini silmek için aşağıdaki metodu kullanabilirsiniz. this.Controls[t].GetType().Name karşılığına "TextBox" dışında ComboBox, CheckBox gibi diğer arayüz öğelerini de ekleyebilirsiniz.

 public void TextBoxSil()

Operation is not valid due to the current state of the object.

ASP.NET üzerinde AjaxcontrolToolkit kullandıysanız, kullandığınız ekranda postback yapılırken "Operation is not valid due to the current state of the object.hatasını alabilirsiniz. Bunu önlemenin yolu .NET frameworkteki MaxHttpCollection ayarını değiştirmekten geçiyor. Web config dosyasına aşağıdaki satırları ilave ettiğinizde sorun düzelecektir.



Web Config üzerinde eklemeniz gereken satır:

< appSettings>
     key="aspnet:MaxHttpCollectionKeys" value="2001"/ >
 < /appSettings>

Hata Ekranı:





ASP.NET üzerinde Butonu disable etmek

ASP.NET üzerinde Butona tıklandığında butonun disable edilmesi için aşağıdaki kod aspx dosyasına eklenir.
UseSubmitBehavior="false" OnClientClick="this.disabled=true;this.value = 'Lütfen Bekleyiniz...';"

Devexpress AspxGridView kolonlarda filtre türünü değiştirme (AutoFilterCondition)

Devexpress AspxGridView kolonlarında filtre türünü değiştirmek için grid üzerindeki ilgili kolonda Settings--> AutoFilterCondition = default yerine Contains yapılır.
Böylece ilgili kolon üzerinde arama yapmak istenildiğinde içinde aranılan karakterleri içeren tüm kayıtlar listelenir.

Devepress ASPxGrid üzerinde Delete/İnsert/Update butonunu gizlemek

Devepress ASPxGridView üzerinde kullanıcı bazında Delete/İnsert/Update butonunu gizlemek gerekebilir. Bu işlemi yapmak için aşağıdaki kod kullanılabilir. 





protected void ASPxGridView1_CommandButtonInitialize(object sender, ASPxGridViewCommandButtonEventArgs e)
        {

          if (e.ButtonType == DevExpress.Web.ASPxGridView.ColumnCommandButtonType.Delete)
                e.Visible = false;
        }

ERROR: The name "UserName" does not exits int the current context? in C sharp

PROBLEM:

ERROR: The name "UserName" does not exits int the current context?

SOLUTION:
The name 'UserName' does not exist in the current context?


1. Left-Click in the "yourUserControl.cs" (solution explorer)

2. Select Properties

3. Change Build Action to "Embededd Resource"

C sharp Türkçe karakter kontrol metodu

Eğer veritabanına Türkçe karakter yazmak istemiyorsanız, aşağıdaki metodu kullanabilirsiniz.

Kullanımı:
_Name += "MAIL_METIN,";
_Values += "'" + Tools.TurkceKarakterleriKaldir(HTMLCode) + "',"; 
public static string TurkceKarakterleriKaldir(string EskiMetin)
{
string YeniMetin = "";
string TurkceKarakterler="şŞçÇüÜİıöÖğĞ";
string YeniKarakterler ="sScCuUIioOgG";
for (int i = 0; i < EskiMetin.Length; i++)
{
bool Varmi = false;
for (int k = 0; k < TurkceKarakterler.Length; k++)
{
if (EskiMetin[i] == TurkceKarakterler[k])
{
YeniMetin += YeniKarakterler[k];
Varmi = true;
break;
}
}
if (!Varmi)
{
YeniMetin += EskiMetin[i];
}
}
return YeniMetin;
}
 

I want to get ASCII value of string in C#, what can I do?

Sample Code:

string value = "9quali52ty3";

// Convert the string into a byte[].
byte[] asciiBytes = Encoding.ASCII.GetBytes(value);

Result:

57 113 117 97 108 105 53 50 116 121 51

How can I get the Selected Item for LookupEdit in C#?

try this:
this.bankaSubeleriIdLookUpEdit.Properties.GetDataSourceValue("IBANNo", this.bankaSubeleriIdLookUpEdit.ItemIndex).ToString();

One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

In Microsoft Visual Studio 2005, you rebuild a solution and try to view a Microsoft Windows Form in Design view. When you do this, Design view may not show the Windows Form. Additionally, you may receive the following error message and call stack:

PROBLEM:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly assembly)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String codeBase)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String codeBase)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

RESOLUTION:

For more information about the MSDN Code Gallery, visit the following Microsoft Web site:
http://code.msdn.microsoft.com/KB912019

To apply this hotfix, you must have Visual Studio 2005 installed on the computer.

Case Problem in C Sharp: Control can't fall through from one case label to another

PROBLEM:
Control can't fall through from one case label to another 4 each case

String status = (String)Session["Status"];

switch (status)
{
case "Book Pending":

string count1 = wucHSRBookModify1.getCount("Offer Pending", "",
"", "", "");
int intcount1 = Convert.ToInt16(count1);
if (intcount1 < 1)
{
wucHSRBookModify1.UpdateBookStatus((String)Session["Status"]);
}

case "Modification Pending":

string count2 = wucHSRBookModify1.getCount("Offer Pending", "Book Pending",
"", "", "");
int intcount2 = Convert.ToInt16(count2);
if (intcount2 < 1)
{
wucHSRBookModify1.UpdateBookStatus((String)Session["Status"]);
}
case "Availability Pending":

string count3 = wucHSRBookModify1.getCount("Offer Pending", "Book Pending",
"Modification Pending", "", "");
int intcount3 = Convert.ToInt16(count3);
if (intcount3 < 1)
{
wucHSRBookModify1.UpdateBookStatus((String)Session["Status"]);
}
}


RESOLUTION:
You need to insert a break; at the end of each case before another case begins.

Reading Information from the LDAP Server with C#

Bring information down from the server and format it into an XmlDocument object. So let's add some variables to our method. I have initialized them to string.Empty and for the instance of AuthenticationTypes, I have initialized it to Anonymous.

string domainAndUsername = string.Empty;
string userName = string.Empty;
string passWord = string.Empty;
AuthenticationTypes at = AuthenticationTypes.Anonymous;


Next we populate the connectivity information with real values:

domainAndUsername = @"LDAP://123.12.12.123/dc=youcanlearnseries,dc=abc.us,dc=com";
userName= "kenno" ;
passWord= "password";
at = AuthenticationTypes.Secure;


Yes, we could have populated this information when we initialized the objects, but if you want to pass in multiple Directory servers, Active Directory, Sun One, etc., then this allows you to create the variable and then populate it later after user input.

Then we create an instance of a DirectoryEntry object. This object encapsulates a node in the Directory Services hierarchy. We pass into the object the connectivity information we created previously.

DirectoryEntry entry = new DirectoryEntry(domainAndUsername,userName, passWord,at);

To actually query the Directory server, we will create an instance of a DirectorySearcher object and we will pass into the DirectorySearcher object the DirectoryEntry object we created in the previous step.

DirectorySearcher mySearcher = new DirectorySearcher(entry);

The results of the query are stored in a collection object, SearchResultCollection, called results.

SearchResultCollection results;

We still want to filter the final results so we add the filter query to the mySearcher object.

mySearcher.Filter = filter;

And finally, we query the LDAP repository, storing the results in the results collection.

results = mySearcher.FindAll();

The rest of the formula is simple yet slightly confusing in its implementation. We have all the information returned for our query of the Directory Server stored in a SearchResultCollection object as a collection of properties and values. We are going to build our own XML object to return to our calling web service. Using a foreach loop, we iterate through the result collection, pulling out properties first and then within each property we find the actual value stored in the hierarchy. The code below has been shortened to show how the loop through the collection works.

foreach(SearchResult resEnt in results)
{
ResultPropertyCollection propcoll=resEnt.Properties;
foreach(string key in propcoll.PropertyNames)
{
foreach(object values in propcoll[key])
{ switch (key)
case "sn":
sb.Append(key.ToString() + ""
+ values.ToString() + "
");
break;
case "cn":
sb.Append(key.ToString() + ""
+ values.ToString() + "
");
break;
case "name":
sb.Append(key.ToString() + ""
+ values.ToString() + "
");
break;
}
}
}
}

The "key" that we need is determined by the LDAP directory you are using. Sun One uses different keys than Microsoft's Active Directory. So the system administrator might be able to inform you of the keys to use for your specific application, or you filter at a higher level and see what keys are returned and break it down yourself.

Each user that we select from our query we are going to wrap in a tag of our XML object. Notice that we create them as a StringBuilder object and then before we send them to the calling object, we load them into an XmlDocument object. We could have created an XML schema and then loaded them into the XmlDocument as we go, but for this example, I felt that was more information than needed.

JavaScript Special Characters in C#

In JavaScript you can add special characters to a text string by using the backslash sign.

Insert Special Characters
The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string.

Look at the following JavaScript code:

var txt="We are the so-called "Vikings" from the north.";
document.write(txt);


In JavaScript, a string is started and stopped with either single or double quotes. This means that the string above will be chopped to: We are the so-called

To solve this problem, you must place a backslash (\) before each double quote in "Viking". This turns each double quote into a string literal:

var txt="We are the so-called \"Vikings\" from the north.";
document.write(txt);


Code Outputs
\' --> single quote
\" --> double quote
\& --> ampersand
\\ --> backslash
\n --> new line
\r --> carriage return
\t --> tab
\b --> backspace
\f --> form feed



Example 2

_List.ListRow.AddColumn("" + GetStatus(_COSTLINE.GetSTATUS()) + " ", "Left", false, "7%");

Expiring a cookie in CSharp

The first thing you need to understand about cookies is this: Cookies carry an expiry date. The second thing you need to understand is this: Expiry dates are the cause of most cookie-related bugs.

Every time you set the Value of a cookie, remember also to set the Expires date. If you fail to do this you will quickly find yourself losing Cookies owing to them having expired immediately when updating them on the client machine or when the browser closes.

When a cookie expires, the client no longer sends it to the server, so you need to make sure that the Expires property of the cookie is always in the future. If you just set a cookie's value then it will create a cookie with Expires set to DateTime.MinValue (01-Jan-0001 00:00).

You can set a cookie's Expires property using any DateTime value (a positive relief after ASP). For example, if you want a Cookie to expire after the user has not been to that part of your site for a week, you would set Expires = DateTime.Now.AddDays(7).

If you want the cookie to be permanent then the temptation is to use DateTime.MaxValue, as I did in the lat version of this article. However, there is a simple gotcha here.

DateTime.MaxValue is precisely 31-Dec-9999 25:59:59.9999999. But Netscape, even at version 7, doesn't cope with that value and expires the cookie immediately. Amazingly, and somewhat annoyingly, investigation showed that Netscape 7 will cope with 10-Nov-9999 21:47:44 but will not handle a second higher (I'll be honest, I didn't test it to any fraction of a second, I really wasn't interested).

Thus if, like me, you subscribe to the "it doesn't have to look pretty on Netscape, as long as it's functional on the latest version" school of thought, always use a date prior to that. A commonly accepted "permanent" cookie expiry date is DateTime.Now.AddYears(30), ie. 30 years into the future. If someone hasn't visited your site for that long, do you really care what the state was last time they were there?

Visual Studio 2017'de Devexpress 17.2.5 Toolbox görünmüyor

Visual Studio 2017 Toolbox'ı üzerinde Developer Express componentlerini göremiyorsanız aşağıdaki komutu çalıştırmak işini görecektir. (...