วันอังคารที่ 29 ธันวาคม พ.ศ. 2552

IIS7 and old asp problem

Yesterday i need to set some asp application on IIS7 (Vista)
and found something (I already install asp component)

If asp have error occur it doesn't show error message and tell me to contact administrator (that's me)

"An error occurred on the server when processing the URL. Please contact the system administrator"

for this go to setting error to show go to root web sites (don't know why set per application not work)
setting in asp
Send Errors To Browser = true

yes after this i see error but it confuse me more
with this word

Active Server Pages error 'ASP 0131'

Disallowed Parent Path

/default.asp, line 1

The Include file '../header.inc' cannot contain '..' to indicate the parent directory.

What this mean yes after research i found IIS7 don't allow parent path for asp by default.
um again.

go to asp setting and set
Enable Parent Paths = true

Yes after this you will see real error come true.

you can use trace your application by Failed Request Tracing Rules for another options about this

วันศุกร์ที่ 25 ธันวาคม พ.ศ. 2552

Break And Continue in loop?

for(int i = 0; i < 10; i++){
if(i == 0) break;
DoSomeThing(i);
}

for(int i = 0; i < 10; i++){
if(i == 0) continue;
DoSomeThing(i);
}

From above code is simple to explain

break is complete stop and exit loop
continue use to stop current loop but can continue to next loop

วันพุธที่ 23 ธันวาคม พ.ศ. 2552

asp:menu problem render with IE8

It will not render correctly until you use Compatible mode to see it work again.
This is bug from ASP.NET not IE 8 and it already have fix patch for this

For more details go here.
http://blogs.msdn.com/giorgio/archive/2009/02/01/asp-net-menu-and-ie8-rendering-white-issue.aspx
and
http://support.microsoft.com/kb/962351

Fix for Windows XP, Windows 2000, Windows Server 2003
http://code.msdn.microsoft.com/KB969612

for Vista and Windows 2008
http://code.msdn.microsoft.com/KB967535

วันพฤหัสบดีที่ 10 ธันวาคม พ.ศ. 2552

If Condition inline in GridView

<ItemTemplate>
<asp:LinkButton ID="uxEditLinkButton" runat="server" CommandName="Edit"
Text="Edit"
Visible='<%# (Eval("PageID").ToString() == "0")? false : true %>'></asp:LinkButton>
</ItemTemplate>

This sample show easy how to hide edit link if PageID == "0" by use condition inline in ItemTemplate for any GridView.

Insert Condition inline in GridView Template

(ItemTemplate>)
(asp:LinkButton ID="uxEditLinkButton" runat="server" CommandName="Edit"
Text="Edit" Visible='(%# (Eval("PageID").ToString() == "0")? false : true %)')(/asp:LinkButton)
(/ItemTemplate)

วันจันทร์ที่ 26 ตุลาคม พ.ศ. 2552

[PHP] การเขียนไฟล์

ใช้คำสั่ง fopen นะคร้าบ

$strFileName = "MyFile.txt";
$objFopen = fopen($strFileName, 'w');
$strText = "Test ja";
fwrite($objFopen, $strText1);

if($objFopen)
{
echo "File writed.";
}
else
{
echo "File can not write";
}

fclose($objFopen);

สำหรับ Mode การเขียนก็มี
r - ไว้อ่านอย่างเดียว
w - ถ้ามีไฟล์อยู่แล้วเขียนทับหรือสร้างใหม่
a - เขียนต่อขอรับ

[PHP] การใช้คำสั่ง Imagestring

ใน php.ini ใช้
extension=php_gd2.dll

เอาไว้ทำรูปภาพอ่ะนะ

วันจันทร์ที่ 19 ตุลาคม พ.ศ. 2552

Prevent Web.config inheritance

add <location inheritInChildApplications="false"> to surround setting section your top level web application

ex.

<configuration>

<location path="." inheritInChildApplications="false">

<system.web>

<!-- Your Setting -->

</system.web>

</location>

</configuration>

How to use SSL in your localhost (IIS)

Use makecert.exe in command line for this job.
I will explain how to used later.

วันพุธที่ 30 กันยายน พ.ศ. 2552

IE8 Bug Margin top after Clear Element

Sample
<div class="floatleft"></div><div class="floatleft"></div>
<div class="Clear"></div>
<div class="MarginTop"></div>

like this margin-top will not correct in only IE8 (- -')

for me to get this work try to add div to cover above missing margin element like this

<div>
<div class="floatleft"></div><div class="floatleft"></div>
<div class="Clear"></div>
</div>
<div class="MarginTop"></div>

This should work (Correctly to display but not flexible to me)

for another solution that i found
<a href="http://www.inventpartners.com/content/ie8_margin_top_bug">http://www.inventpartners.com/content/ie8_margin_top_bug</a>

This have about 3 solution to fix this.

วันอาทิตย์ที่ 5 กรกฎาคม พ.ศ. 2552

Boost Performance for my Vista

I use Steam to load my game in notebook but i found full memory after few hours.
Becuase of this i must find a way to boot my perfomance and i found some.
-Disable SuperFetch
Goto run and typing services.msc
Find Supefetch in list and disable it

SuperFetch use to preload your application that we use often, if you have more ram
it will make your application run fast, but we are gamer we don't need it
(I don't play game for awhile but i developer i need more ram too)

วันพฤหัสบดีที่ 2 กรกฎาคม พ.ศ. 2552

Kaspersky Block some image in browser. (This happen with my Google Analytics can't work correctly)

Because Banner block function in Kaspersky
so don't try to have image in folder name banner or this word in file name. (ads too)

for all website to show banner correctly disable this function in Kaspersky or
add whitelist to Kaspersky banner function.

วันศุกร์ที่ 19 มิถุนายน พ.ศ. 2552

IE p tag problem when insert in another tag p

In IE 7 and IE8 (that i test with myself)
It will render not cerrect like this sample
<p>c
<p>a</p>
<p>b</p>
</p>

in source it look ok but in IE render view is
<p>c</p>
<p>a</p>
<p>b</p>
</p>

the thing i want to tell is don't try put tag p in another tag p change outer tag p to div
it will ok.

วันอาทิตย์ที่ 24 พฤษภาคม พ.ศ. 2552

PHP Cookie and "Cannot modify header information"

Today i use setCookie in my project and this code is the most top line
but they warning "Cannot modify header information"

I used ob_start(); but this code did not help anything

so for me i found this solution
Please check your all file encoding because this error happen with UTF8 with signature
(include have some strange line empty)

Change it to UTF8 without signature can help.
cheers.

วันจันทร์ที่ 11 พฤษภาคม พ.ศ. 2552

Unknow files (blank files) in Media Player 11 List

This files Can't access and Can't delete (if you selected all and remove all this file still be there)

simply solution is because Windows Media cache files

For vista
Goto

Local Disck > Users > XXX (Your User Name)>AppData>Local>Microsoft>Media Player

Delete All *.wmdb for manual reset cache Windows Media files

Now Go back to your Windows Media Player and see problem Unkonw files are gone

วันศุกร์ที่ 8 พฤษภาคม พ.ศ. 2552

PHP แปลงข้อมูลจาก String เป็นวันที่ (convert string to datetime)

ใช้เวลาเอาออกมาจาก MySQL ได้ผลดีนักแล เวลาเทียบเวลาใด ๆ โปรดใช้ timestamp นะครับ

MySQL Keep data in DateTime Format but read out in string.
To use that value try to convert to timestamp in PHP
and after on you go.

$str = 'Not Good';

// previous to PHP 5.1.0 you would compare with -1, instead of false
if (($timestamp = strtotime($str)) === false) {
echo
"The string ($str) is bogus";
} else {
echo
"$str == " . date('l dS \o\f F Y h:i:s A', $timestamp);
}
?>

วันศุกร์ที่ 3 เมษายน พ.ศ. 2552

Ms SQL กับการใช้สคริป (Znode Store Script)

พอดีว่า วันนี้ต้องเทส Znode ซึ่งตัวโปรแกรมมี Trial มาให้
เอามาลองใช้ดูปรากฎว่า นำเข้า Database ไม่ได้ ตรวจ Error ดู ก็พอว่า
ฐานข้อมูลของเรา ใช้ Collation เป็น Thai_CI_AS
แต่ของ Znode ใช้ Collation เป็น SQL_Latin1_General_CP1_CI_AS
ทำให้บางคำสั่งไม่สามารถนำเข้าได้อย่างถูกต้อง

วิธีแก้ก็ง่ายๆ ลบขั้นตอนการสร้างฐานข้อมูลใน สคริปของ Znode ออกแล้ว สร้างฐานข้อมูลใหม่ของเราเอง แล้วไปตั้งค่า Collation ใน Database ให้ตรงกับใน Script แค่นั้นเอง

จริงๆ ก็น่าะมีคำสั่งเปลี่ยน Collation ใน Script เองนะ แต่เอาไว้ค่อยหาละกัน ตอนนี้แก้ไปอย่างนี้ก่อน

วันอังคารที่ 24 มีนาคม พ.ศ. 2552

Microsoft Office Outlook Connector 12.1 + Outlook 2007 + Thai switch langauge = Crash

ปัญหามีอยู่ว่า พิมพ์แล้วกดสลับภาษา (ปุ่มไหนก็ได้ ไม่ว่าจะตั้งปุ่มอะไร) จะเกิดการ crash ของ outlook ทันที ซึ่ง ถ้าหากกดสลับภาษาที่ ช่อง ด้านบน (ชื่อผู้รับ สำเนาผู้รับ หรือ หัวข้ออีเมล) จะไม่เกิดปัญหา แต่ถ้าไปสลับในช่อง Body Message เมื่อไหร่ เดี้ยงทันที

ซึ่งการป้องกันการเดี้ยง ทำได้โดย สลับภาษาในช่องด้านบน หรือ คลิกเปลี่ยนภาษาด้วยเมาส์ที่ ตัวสลับภาษาที่ taskbar หรือ พิมพ์ใน Notepad แล้ว copy มาใส่ หรือ ไม่ต้องสลับภาษา - -'

ซึ่งยุ่งยากนัก จริงๆ ลบตัว Outlook Connector ออกไปเลย ก็แก้ปัญหาได้แล้ว
แต่การต่อ Outlook แบบเดิม มันไม่โหลดเมลมาให้ทั้งฉบับ มันโหลดมาให้แต่หัว
ทีนี้ใช้ Search มันหาได้ไม่ครบน่ะสิ

ตัว Outlook Connector มีประโยชน์นะ แต่ว่ามันมีบักตรงนี้ ตอนนี้ก็แก้ขัดไปก่อนด้วยไปพิมพ์ข้อความใน Notepad แล้วก็อบเอามาใส่ เง้อ

แก้คำผิดนิดหน่อยคร้าบ - 2009-05-25

วันศุกร์ที่ 20 กุมภาพันธ์ พ.ศ. 2552

Get Image from stream use local path.

have only one sample function here

        private Image GetImageFromLocal( string localPath )
        {
            using (FileStream fs = new FileStream( localPath, FileMode.Open, FileAccess.Read ))
            {
                Image img = Image.FromStream( fs );
                return img;
            }            
        }

Don't sure about performance from local or url and if found bad data.
I will try test later.

Get image from stream url.

have 2 sample function for this (c#)

1.
            private Image GetImage(string sURL)
            {
                Stream str = null;
                HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(sURL);
                HttpWebResponse wRes = (HttpWebResponse)(wReq).GetResponse();
                str = wRes.GetResponseStream();

               return Image.FromStream(str);
            }

2.
       private Image GetImageFromURL( string strURL )
        {
            //Initialize the return value 
            Image retVal = null;

            //Any errror while connecting to the server or streaming the data into an image can result in an exception! dont forget to use a try{}catch{} block! 
            try
            {
                //We use the HttpWebRequest object to connect to a web site: 
                HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create( strURL );

                //Be sure to populate the time out values in the request :) 
                request.Timeout = 10000; // 10 seconds in milliseconds
                request.ReadWriteTimeout = 40000; // allow up to 40 seconds to elapse

                //Retrieving the stream of data from the web server is very easy: 
                // execute the request
                HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();

                //Now we convert the downloaded stream into an Image! 
                retVal = Image.FromStream( response.GetResponseStream() );
            }

            //Perform cleanup on an exception:
            catch (Exception)
            {
                retVal = null;
            }

            //Thats it! now we return the image :) 
            return retVal;
        }
sorry I can't remember for this reference i wrote this because i found problem about memory full by get Image use Image.GetFromFile so use stream can help alot.

วันศุกร์ที่ 23 มกราคม พ.ศ. 2552

_doPostBack กับ Hidden Value

Asp.net การทำงานแบบ Ajax เราสามารถเก็บค่าเอาไว้ใน Hidden value แทน Viewstate ได้  แต่เมื่อต้องการจะนำมาใช้  จะดึงค่ามาใช้ได้ตอน Page_PreRender นะคร้าบ

วันจันทร์ที่ 12 มกราคม พ.ศ. 2552

Enum to String and String to Enum

Enum to String
Enum.GetName( typeof(EnumType), mode)

String to Enum
(EnumType)Enum.Parse(typeof(EnumType);, EnumValue, true);

วันศุกร์ที่ 9 มกราคม พ.ศ. 2552

Generate key file (*.snk) by sn.exe

Go to Visual Studio Tool For "Visual Studio 2xxx Command Prompt
and type "sn.exe -k xxxx.snk"
Example

sn.exe -k c:\myKeyFile.snk

this will generate myKeyFile.snk to C:\