blog html code editor

http://www.simplebits.com/cgi-bin/simplecode.pl

internet explorer 7 and 8 updatepanel rendering error


Örneğin aşağıdaki gibi bir kullanım IE7 ve IE8’de hataya (UpdatePanel’in çalışmamasına) neden oluyor:

<table>
<tr>
<td>
...
</td>
</tr>
<asp:UpdatePanel …>

</asp:UpdatePanel …>
<tr>
<td>
...
</td>
</tr>
</table>

Yukarıdaki örnekte UpdatePanel uygun olmayan yerde bulunuyor. Şu hale çevirince düzeliyor:

<table>
<tr>
<td>
...
</td>
</tr>
</table>
<asp:UpdatePanel …>

</asp:UpdatePanel …>
<table>
<tr>
<td>
...
</td>
</tr>
</table>

consuming web service using webrequest

public const string WebServiceUrl = "https://xxx.xxx.com.tr/server/cms";
const string methodName = "PR_SWEP_URT_OTO_WS_KASKO_TEKLIF_POLICELENDIR";

doc.LoadXml(xmlRequest);
var req = (HttpWebRequest)WebRequest.Create(Constants.WebServiceUrl);
req.Headers.Add("SOAPAction", Constants.WebServiceUrl + "/" + methodName);
req.Headers.Add("Operation", methodName);
req.Headers.Add("Style", "RPC");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
var stream = req.GetRequestStream();
doc.Save(stream);
stream.Close();


public const string WebServiceUrl = "http://xx.xx.xxx.xxx:xxxx/PolServis";
const string methodName = "getKaskoPolice";

doc.LoadXml(xmlRequest);
var req = (HttpWebRequest)WebRequest.Create(Constants.WebServiceUrl + "/services/KaskoPoliceServis?wsdl");
req.Headers.Add("SOAPAction", Constants.WebServiceUrl + "/" + methodName);
req.Headers.Add("Operation", methodName);
req.Headers.Add("Style", "RPC");
req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
var stream = req.GetRequestStream();
doc.Save(stream);
stream.Close();

java.lang.NumberFormatException HTTP Error 500 Internal server error

AracBedeli 29750,00 formatında gönderildiğinde şu satırda hata oluşuyor:

var webResponse = req.GetResponse();

HTTP Error 500 Internal server error hatası dönüyor.
Ama SoapUI'da hatanın nedeni görülebiliyor:

soapenv:Server.userException java.lang.NumberFormatException: Not a valid char constructor input: 29750,00

Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator

code:
var cpList2 = (from customerProduct in _context.customer_products
join controlPolice in controlPolices
on customerProduct.sales_ID equals controlPolice.sales_ID
where customerProduct.yenileme_no == controlPolice.yenileme_no
&& customerProduct.zeyil_no == controlPolice.zeyil_no
select customerProduct);

error:
Local sequence cannot be used in LINQ to SQL implementation of query
operators except the Contains() operator

solution:
var cpList = (from controlPolicy in controlPolicies
join customerProduct in _context.customer_products
on controlPolicy.sales_ID equals customerProduct.sales_ID
where controlPolicy.yenileme_no == customerProduct.yenileme_no
&& controlPolicy.zeyil_no == customerProduct.zeyil_no
select customerProduct);

source:
http://stackoverflow.com/questions/5936301/local-sequence-cannot-be-used-in-linq-to-sql-implementations-of-query-operators-e

How to enumerate an enum?

How to enumerate an enum?

public static class EnumExtensions
{
///


/// Gets all items for an enum value.
///

///
/// The value. ///
public static IEnumerable GetAllItems(this Enum value)
{
foreach (object item in Enum.GetValues(typeof(T)))
{
yield return (T)item;
}
}

///
/// Gets all items for an enum type.
///

///
/// The value. ///
public static IEnumerable GetAllItems() where T : struct
{
foreach (object item in Enum.GetValues(typeof(T)))
{
yield return (T)item;
}
}

///
/// Gets all combined items from an enum value.
///

///
/// The value. ///
///
/// Displays ValueA and ValueB.
///
/// EnumExample dummy = EnumExample.Combi;
/// foreach (var item in dummy.GetAllSelectedItems())
/// {
/// Console.WriteLine(item);
/// }
///

///

public static IEnumerable GetAllSelectedItems(this Enum value)
{
int valueAsInt = Convert.ToInt32(value, CultureInfo.InvariantCulture);

foreach (object item in Enum.GetValues(typeof(T)))
{
int itemAsInt = Convert.ToInt32(item, CultureInfo.InvariantCulture);

if (itemAsInt == (valueAsInt & itemAsInt))
{
yield return (T)item;
}
}
}

///
/// Determines whether the enum value contains a specific value.
///

/// The value. /// The request. ///
/// true if value contains the specified value; otherwise, false.
///

///
///
/// EnumExample dummy = EnumExample.Combi;
/// if (dummy.Contains(EnumExample.ValueA))
/// {
/// Console.WriteLine("dummy contains EnumExample.ValueA");
/// }
///

///

public static bool Contains(this Enum value, T request)
{
int valueAsInt = Convert.ToInt32(value, CultureInfo.InvariantCulture);
int requestAsInt = Convert.ToInt32(request, CultureInfo.InvariantCulture);

if (requestAsInt == (valueAsInt & requestAsInt))
{
return true;
}

return false;
}
}

The enum itself must be decorated with the FlagsAttribute

[Flags]
public enum EnumExample
{
ValueA = 1,
ValueB = 2,
ValueC = 4,
ValueD = 8,
Combi = ValueA | ValueB
}

http://stackoverflow.com/questions/105372/c-how-to-enumerate-an-enum

generic list sorting - order by

If you mean an in-place sort (i.e. the list is updated):

people.Sort((x, y) => string.Compare(x.LastName, y.LastName));
If you mean a new list:

var newList = people.OrderBy(x=>x.LastName).ToList(); // ToList optional

http://stackoverflow.com/questions/188141/c-list-orderby-alphabetical-order

Unable to make the session state request to the session state server

Error:
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.

Resolution:
ASP.Net State Service maybe doesn't work, or isn't enabled.
To start it go to Administrative Tools --> Services --> ASP.Net State Service...

To enable it go to Administrative Tools --> ... --> IIS ...
On Windows 7 go to --> Programs and Features --> ... --> ASP.Net ...

Tips & Tricks for English learners

http://www.english.hb.pl/articles/tips/

Learning English - tips

- Mnemonics and mind maps

- Learn English with Google

- Song lyrics in Winamp

- SuperMemo FAQ

------------------------------------------------------------------------------------------------

http://www.ehow.com/list_6538175_tricks-learn-english.html

Learning English is an arduous endeavor for many people. Some beginners hope to master the language right away, but the difficulties they may encounter in the initial stages of the learning process can be discouraging. New learners should remain steadfast in their efforts and employ strategies that strengthen their commitment, patience, knowledge retention and, perhaps most importantly, enjoyment throughout the learning experience.

Converse with Native English Speakers
Native English speakers possess a natural flow in their speech that beginners should try to emulate. Over time, practicing speech with a native speaker will help a beginner pronounce awkward words with ease and confidence. Additionally, beginners can familiarize themselves with idiomatic phrases that may be challenging for them to recognize and fully understand in the early stages of learning; native speakers can help convey their meanings more clearly. Moreover, forging a friendship enhances the enjoyment of the learning process.

Set Achievable Targets
It is important for beginners to set realistic targets so the learning experience is an encouraging--rather than frustrating--one. Goals such as reading a brief news article every day, learning 10 new words throughout the week or listening to a talk radio show every other day are small but achievable and allow learners to progress gradually. Measured improvement strengthens motivation and confidence; on the other hand, setting an overly ambitious goal--such as completely understanding a complex and lengthy novel in just three weeks--can lead to a new learner's unwarranted sense of failure.

Speech Recording
The LEO Network reports that an auditory learner who interprets the meanings of speech more effectively through listening to intonation, pitch, speed and other nuances can benefit from making a recording of her speech. She then can replay the recording and gauge which words are most problematic for her to articulate. This self-awareness can stimulate her improvement, as she is able to make a more conscious effort when pronouncing difficult words.

English Films, TV Shows and Songs
Watching English films and television shows and singing along to English songs are entertaining learning methods. Watch films and shows with English subtitles and print out the lyrics to favorite songs in order to learn vocabulary more effectively.

Structured Instruction
English instruction classes provide a student with the structured tutorial, deadlines, homework and tests that can strengthen his chances for success. He also can benefit from being a part of a supportive community of new learners who share his experience. If needed, private instruction is also an option.

linq clone error

error:

Object graph for type 'Uye.UyeMacAdresi' contains cycles and cannot be serialized if reference tracking is disabled.

solution:

in dbml file change the 'Serialization Mode' to 'Unidirectional'

method overload with single method

private void ShowInfo(string info, bool stayOnPage = true)
{
PopupInfo1.SetFunctionality(stayOnPage);
}

usage:

ShowInfo("Policy not found!");

or

ShowInfo("Policy not found!", false);

t-sql - Retrieving Error Information

-- Create procedure to retrieve error information.
CREATE PROCEDURE usp_GetErrorInfo
AS
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
GO

-- Sample:
BEGIN TRY
-- Generate divide-by-zero error.
SELECT 1/0;
END TRY
BEGIN CATCH
-- Execute error retrieval routine.
EXECUTE usp_GetErrorInfo;
END CATCH;

http://msdn.microsoft.com/en-us/library/ms175976.aspx

linq - Row not found or changed

trouble:

var daskTeklif = _context.tblDaskTeklifs.SingleOrDefault(dt => dt.teklif_id == TeklifTkID);
daskTeklif.SirketPoliceNo = policeNo;
_context.SubmitChanges();

throws an exception: System.Data.Linq.ChangeConflictException: Row not found or changed.

solution:

creating a new datacontext:

var context = new DataClassesDataContext();
daskTeklif = context.tblDaskTeklifs.SingleOrDefault(dt => dt.teklif_id == TeklifTkID);
daskTeklif.sirketPoliceNo = policeNo;
context.SubmitChanges();

cycle error on cloning linq object

error: "Object graph for type 'TestLinq.PersonAddress' contains cycles and cannot be serialized if reference tracking is disabled.”

solution: change the 'Serialization Mode' to 'Unidirectional'.

source: http://stackoverflow.com/questions/1432501/clone-linq-object-error-object-graph-for-type-testlinq-personaddress-contains

clone linq object

///



/// Clones any object and returns the new cloned object.
///

/// The type of object.
///
The original object./// The clone of the object.
public static T Clone(T source)
{
var dcs = new DataContractSerializer(typeof(T));
using (var ms = new System.IO.MemoryStream())
{
dcs.WriteObject(ms, source);
ms.Seek(0, System.IO.SeekOrigin.Begin);
return (T)dcs.ReadObject(ms);
}
}


source:http://stackoverflow.com/questions/2178080/linq-to-sql-copy-original-entity-to-new-one-and-save

search this blog (most likely not here)