function pageLoad()
{
var instance = Sys.WebForms.PageRequestManager.getInstance();
instance.add_endRequest(ehandler);
}
function ehandler(s, e)
{
if (e.get_error() != undefined)
{
e.set_errorHandled(true);
}
}
Thursday, March 12, 2009
AJAX Error Handle
Sunday, February 15, 2009
LINQ And Picture
TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap b = (Bitmap)tc.ConvertFrom(c.Picture);
b.Save(context.Response.OutputStream, ImageFormat.Jpeg);
b.Dispose();
Wednesday, February 11, 2009
Silverligt UploadStringAsync ve Ado.net DataService
string uri = Application.Current.Host.Source.AbsoluteUri; int index = uri.IndexOf("/ClientBin"); uri = uri.Substring(0, index); WebClient wc = new WebClient(); wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; var query = "ad=" + txtAd.Text + "&soyad=" + txtSoyad.Text; wc.UploadStringAsync(new Uri(uri + "/Default.aspx"), query); wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted);
Monday, February 9, 2009
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.blabla.com/"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
You encounter this error in the web.config file and enter the above code in the part.
Wednesday, February 4, 2009
Silverlight and Cookie
DateTime expiration = DateTime.Now.AddDays(5);
string cookie = string.Format("ad={0};expires={1}", txtCookie.Text, expiration.ToString("R"));
HtmlPage.Document.SetProperty("cookie", cookie);
Read All Cookies in Silverlight
var cooks = HtmlPage.Document.Cookies.Split(';');
foreach (var s in cooks)
{
cook = s.Split('=');
MessageBox.Show(cook[1]);
}
This also can easily access cookies by asp.net.
SilverLight And Double Click
Normally, double-click does not exist in Silverlight.But within a period of time after you press the left button pressing the left button double click event in a more duration 300 ms.
public partial class Page : UserControl
{
DispatcherTimer timer;
public Page()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(300);
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
}
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (timer.IsEnabled)
{
MessageBox.Show("Double Clicked.");
}
else
{
timer.Start();
}
}
}
Sunday, February 1, 2009
Sql Server Read An External Scheme and Create
select @schema=c from openrowset(bulk 'c:\data.xsd',single_blob) as temp(c)
create xml schema collection DataSchema as @schema
Tuesday, January 20, 2009
Call A Javascript Function With Silverlight
script.InvokeSelf();
İlk satırda sayfasımızda yer alan ChangeImg adlı fonksiyona erişiyoz ve alt satırda bu fonksiyonu çalıştırıyoruz.
Eğer parametre göndermek istersek;
script.InvokeSelf("par1","par2");
Monday, January 19, 2009
Read A Xml Document With Silverlight(XLINQ)
{
string uri = Application.Current.Host.Source.AbsoluteUri;
int index = uri.IndexOf("/ClientBin");
uri = uri.Substring(0, index);
txtAd.Text = uri;
WebClient client = new WebClient();
client.DownloadStringAsync(new Uri(uri+"/data.xml"));
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
}
okuma tamamlandığında ise;
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
XElement element = XElement.Parse(e.Result);
txtAd.Text = (from x in element.Descendants("musteri")
select x.Element("ad").Value).First();
}
catch (Exception ex)
{
System.Windows.Browser.HtmlPage.Window.Alert(ex.InnerException.Message);
}
}
Silverlight Send Parameter And Start Random Page
var myPage=(UserControl)this.GetType().Assembly.CreateInstance(this.GetType().Namespace + "." + ad);
this.RootVisual = myPage;
veya daha kolay olarak girilen parametreye sayfayı belirleriz.
switch (ad)
{
case "Page1":
this.RootVisual = new Page1();
break;
case "Page2":
this.RootVisual = new Page2();
break;
default:
this.RootVisual = new Page();
}
Silverlight ve font embed
Daha sonra bu fontu kullanacağımız elemente aşğıdakini yazınız;
FontFamily="consola.ttf#Consolas"
Sunday, January 18, 2009
Silverlight And Path Files
SilverLight ve Wcf web service
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
return base.CreateServiceHost(serviceType, new Uri[] { new Uri("http://www.yoursite.com/Service.svc") });
}
Service sınıfınıda ServiceHostFactory sınıfından türetin.
The "function name" is not a recognized built-in function name'.
The current database compatibility level does not support managed objects
exec sp_dbcmptlevel 'Northwind', 90
Saturday, January 17, 2009
Trigger and Cursor
on musteri
instead of delete
as
declare @myid int;
declare id_cursor cursor
for
select ID from deleted;
open id_cursor;
fetch next from id_cursor into @myid;
while @@fetch_status=0
begin
print @myid;
fetch next from id_cursor into @myid;
end
close id_cursor;
deallocate id_cursor;
İnstead of triggeri ile musteri tablomuzda silinen musterilerin ID lerini sqlserverda ekrana basıyoruz.
Random Five Record With SqlServer
Friday, January 16, 2009
linq and left join
join n in db.Urunlers
on m.ID equals n.musteriID into records
from r in records.DefaultIfEmpty()
select new { Ad=m.ad, Urun=r.urun ?? "Urun Yok." };
Thursday, January 15, 2009
Sql Server Enable Full Text Searching
komutu çalıştırılır.
Daha sonra ile ilgili tabloya sağ tıklanır ve full text index seçilir.
Friday, January 9, 2009
Linq ve XPathSelectElement
XPathSelectElement metodunu kullanabilmek için önce System.Xml.XPath namespace ini projeye dahil etmek gerekir.
XDocument xDocument = new XDocument(
new XElement("Musteriler",
new XElement("Musteri",
new XAttribute("meslek", "Ogretmen"),
new XElement("ad", "Engin"),
new XElement("soyad", "Guven")),
new XElement("Musteri",
new XAttribute("meslek", "Doktor"),
new XElement("ad", "Hasan"),
new XElement("soyad", "Tekin"))));
ile bir xml dokumanı oluşturuyoruz. Daha sonra;
XElement element = xDocument.XPathSelectElement("Musteriler/Musteri[@meslek='Ogretmen']");
ile mesleği öğretmen olan kaydı seçiyoruz. Eğer bu kaydın adını yazdırmak istersek
Response.Write(element.Element("ad").Value);
Eğer xml dokumanımızdaki attribute göre değilde element değerine göre yapmak isteseydik;
XElement element = xDocument.XPathSelectElement("Musteriler/Musteri[ad='Engin']");
Wednesday, January 7, 2009
Insert and Select Operations With ExecuteMethodCall
(
@ad varchar(50),
@soyad varchar(50)
)
AS
insert into musteri(ad,soyad) values(@ad,@soyad)
select * from musteri where num=scope_identity()
Stored Proceduremiz önce veri ekliyo sonra eklenmiş olan veriyi geri gönderiyor.
[Function(Name="dbo.MusInsert")]
[ResultType(typeof(musteri))]
public IMultipleResults MusInsert([Parameter(DbType="VarChar(50)")] string ad, [Parameter(DbType="VarChar(50)")] string soyad)
{
var result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), ad, soyad);
return (IMultipleResults)result.ReturnValue;
}
Burada ResultType(typeof(musteri))] ile geri dönecek olan verinin hangi nesne tipinde olduğunu
yazmak gerekir.
Iequalitycomparer Sorting Objects
{
#region IEqualityComparer
public bool Equals(musteri x, musteri y)
{
if ((x.ad.Trim() == y.ad.Trim()) && (x.soyad.Trim() == y.soyad.Trim()))
{
return true;
}
else
{
return false;
}
}
public int GetHashCode(musteri obj)
{
return base.GetHashCode();//important code.
}
#endregion
}
Buradan siz müşteri için kendi özel nesnenizi yazınız.