tag:blogger.com,1999:blog-91535611848482779232024-03-05T03:57:37.476-05:00My Tech NotesBlog programming issues I encountered.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-9153561184848277923.post-73789848136028951702010-09-24T16:08:00.000-04:002010-09-24T16:08:01.576-04:00Rails - RJS ERROR: TypeError element is nullUsually this error is caused by "page.replace_html 'div_1', render()". Do you have "div_1" defined anywhere in the html?Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-58571298647286698652010-03-31T10:30:00.001-04:002010-03-31T10:38:10.328-04:00Javascript in Rails PartialJavascript function defined in a partial sometimes doesn't work (I've seen both worked case and non-worked case). I have a partial named _v_1_0_edit.html.erb; its parent page is index.html.erb. The javascript portion is below:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">function my_alert() {</div><div style="font-family: "Courier New",Courier,monospace;"> alert("Hello");</div><div style="font-family: "Courier New",Courier,monospace;">}</div><br />
If the above is inside a partial, it doesn't work when I call my_alert() from a onclick event of a button on the partial; it is as if the function is not defined. But if the above is inside the parent, it works.<br />
<br />
However, if I change the function definition to below:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">my_alert = function my_alert() {</div><div style="font-family: "Courier New",Courier,monospace;"> alert("Hello");</div><div style="font-family: "Courier New",Courier,monospace;">}</div><br />
<span style="font-size: x-small;"><span style="font-family: "Courier New",Courier,monospace;"></span></span>It works if it's defined in a partial (But it doesn't work in IE).<br />
<br />
If I just throw the below on a view:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">alert("Hello");</div><br />
It will show the alert message no matter it's on the partial or the parent.<br />
<br />
I need to do more research on this. I think as long as the defined function is shown on page source, it should work. Can I have a script<br />
section inside a div?Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com1tag:blogger.com,1999:blog-9153561184848277923.post-44192037311029742612009-10-07T17:28:00.002-04:002009-10-07T17:28:34.328-04:00VS2008 Remote DebuggingFirst you need to create a user on your desktop and the remote machine with the same username and password on both machines.<br />
Make sure msvsmon.exe is installed on the remote computer. It should be in your Visual studio 2008 directory.<br />
on the remote computer do a runas /user:debuguser c:\fullpath\msvsmon.exe<br />
where debuguser is the user you created above<br />
You should see a window popup saying "3/31/2009 12:22:56 PM Msvsmon started a new server named 'debuguser@TSIK2552100'. Waiting for new connections."<br />
now on your desktop do a runas /user:debuguser "c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"<br />
where debuguser is again the user you created above<br />
the load your project and go to attach to process, enter debuguser@remotemachinename in the Qualifier box and you may need to select the show processes from all users check box. select your process and you should be able to debug.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-65778748058896966972009-09-28T13:52:00.000-04:002009-09-28T13:52:41.659-04:00Enable Sql Server Authentication Mode Over NetworkCheck the followings:<br />
1. Right click the root node on Object Explorer, in Server Properties window->Security->Server authentication: SQL Server and Windows Authentication mode<br />
2. Create a new user for login.<br />
3. Right click the user on Object Explorer, in Login Properties window:<br />
3.1 User Mapping: Check the desired database to access<br />
3.2 Status->Permission to connect to database engine: Grant; Login: Enabled<br />
4. Sql Server Configuration Manager -> Enable TCP/IP and Named Pipes<br />
5. REMEMBER TO RESTART THE MSSQLSERVER SERVICE.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-19499248846340344002009-09-17T15:24:00.001-04:002009-10-21T17:36:15.249-04:00Object.GetHashCode, Object.Equals, operator==, and relatedAfter some research, I summarize some points below as guidelines.<br />
<br />
1. <strike>Object.Equals method and operator== are supposed to be used interchangeably. (It applies to all the .net classes) Therefore, when implementing a new class, it's a good idea to always implement both of them.</strike><br />
Equals() is usually used (implemented) for value equality and Operator== is used for reference equality by default. When a type is an immutable type (e.g. String), overloading Operator== to compare value equality makes sense.<br />
<br />
Guidelines for Overloading Equals() and Operator==<br />
http://msdn.microsoft.com/en-us/library/ms173147%28VS.80%29.aspx<br />
<br />
Override equals on overloading operator equals<br />
http://msdn.microsoft.com/en-us/library/ms182357%28VS.80%29.aspx<br />
<br />
When should I use == and when should I use Equals<br />
http://blogs.msdn.com/csharpfaq/archive/2004/03/29/102224.aspx<br />
<br />
2. It is important to override GetHashCode when overriding Equals method. Although failure to do so will not always break your code, things can go wrong if the class is used as a key in a dictionary etc. In that situation, if the hash-code for two items does not match, they may never be considered equal (Equals will never be called). To write the GetHashCode, we need to make sure that: if two objects are equal, then they must return the same value for GetHashCode. On the other hand, we do NOT have to make sure two different objects always return different values for GetHashCode.<br />
<br />
Why is it important to override GetHashCode when Equals method is overriden in C#<br />
http://stackoverflow.com/questions/371328/why-is-it-important-to-override-gethashcode-when-equals-method-is-overriden-in-c<br />
<br />
3. A good implementation of GetHashCode that can be used in many situations:<br />
<pre class="prettyprint"><code>public int GetHashCode()
{
int hash = 17;
// Suitable nullity checks etc, of course :)
hash = hash * 23 + field1.GetHashCode();
hash = hash * 23 + field2.GetHashCode();
hash = hash * 23 + field3.GetHashCode();
return hash;
}
</code></pre>What is the best algorithm for an overridden System.Object.GetHashCode<br />
http://stackoverflow.com/questions/263400#263416<br />
<br />
4. Implementing IEquatable Properly<br />
http://www.codeproject.com/KB/dotnet/IEquatable.aspxXiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-81353911534193768172009-08-25T16:20:00.000-04:002009-08-25T16:22:30.731-04:00Sql Server Script to Restore a Databaseuse master<br /><br />alter database DBName<br />set single_user with rollback immediate<br /><br />restore database DBName<br />from disk = 'C:\DBBackup.bak'<br /><br />-- use the following to overwrite log in case the log file was not backed up<br />with replaceXiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-45425472656345747662009-08-18T09:23:00.000-04:002009-08-18T09:49:18.529-04:00SQL Commands - Disable ConstraintsThe following commands are from this URL<br />http://gchandra.wordpress.com/2008/02/18/sql-server-clean-your-database-records-and-reset-identity-columns-the-shortest-path/<br /><br />--Disable Constraints & Triggers <br />exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' <br />exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL' <br /> <br />--Perform delete operation on all table for cleanup <br />exec sp_MSforeachtable 'DELETE ?' <br /><br />--Enable Constraints & Triggers again <br />exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL' <br />exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL' <br /> <br />--Reset Identity on tables with identity column<br />exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END' <br /><br />I found the commands are very useful. For example, I once got the foreign key constraint error when trying to import data into my database. I executed the first two commands to disable constraints and triggers first, then imported the data, the errors were gone. After importing data, I then executed the last three commands to re-enable and reset stuff.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-17318876069579366472009-07-22T17:24:00.000-04:002009-07-22T17:32:06.112-04:00WaitCallback method has to be staticThe following is a demo for using WaitCallback delegate. Note that the method ThreadProc has to be static.<br /><br />using namespace System;<br />using namespace System::Threading;<br />ref class Example<br />{<br />public:<br /><br /> // This thread procedure performs the task.<br /> static void ThreadProc( Object^ stateInfo )<br /> {<br /><br /> // No state object was passed to QueueUserWorkItem, so <br /> // stateInfo is 0.<br /> Console::WriteLine( "Hello from the thread pool." );<br /> }<br /><br />};<br /><br />int main()<br />{<br /><br /> // Queue the task.<br /> ThreadPool::QueueUserWorkItem( gcnew WaitCallback( Example::ThreadProc ) );<br /> Console::WriteLine( "Main thread does some work, then sleeps." );<br /><br /> // If you comment out the Sleep, the main thread exits before<br /> // the thread pool task runs. The thread pool uses background<br /> // threads, which do not keep the application running. (This<br /> // is a simple example of a race condition.)<br /> Thread::Sleep( 1000 );<br /> Console::WriteLine( "Main thread exits." );<br /> return 0;<br />}<br /><br />If it's not static, we'll get the following error:<br />error C3867: 'Example::ThreadProc': function call missing argument list; use '&Example::ThreadProc' to create a pointer to member<br />error C3350: 'System::Threading::WaitCallback' : a delegate constructor expects 2 argument(s)<br /><br />Why??Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com1tag:blogger.com,1999:blog-9153561184848277923.post-66651995239380488882009-06-24T16:26:00.000-04:002009-06-24T16:49:15.286-04:00Calling javascript from code behindPreviously, we know how to easily call server side method from javascript. The opposite is also simple enough.
<br />
<br />Just use the RegisterClientScriptBlock method of ClientScriptManager (in case of full postback) or ScirptManager (in case of patial postback). Following is an example:
<br />
<br /><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]--> <p class="MsoNormal"><span style="line-height: 115%;font-family:";font-size:10;" >ScriptManager</span><span style="line-height: 115%;font-family:";font-size:10;" >.RegisterClientScriptBlock(<span style="color:blue;">this</span>, <span style="color:blue;">this</span>.GetType(), <span style="color: rgb(163, 21, 21);">"confirmInPageNav"</span>, <span style="color: rgb(163, 21, 21);">"<script>confirmInPageNav()</script>"</span>, <span style="color:blue;">false</span>);</span></p>
<br />
<br />confirmInPageNav can be any javascript functionXiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com2tag:blogger.com,1999:blog-9153561184848277923.post-11231688896557281862009-06-16T10:04:00.000-04:002009-06-16T10:23:18.610-04:00Calling server side method from client (using javascript)I didn't know how easy to achieve this until I read the post in this link:
<br />http://disturbedbuddha.wordpress.com/2008/01/08/executing-server-side-code-from-javascript/
<br />
<br />The essence is to put the server side logic in a button's OnClick event handler; then use the HTML DOM click() method to raise the OnClick event.
<br /><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;"><</span><span style="color: rgb(163, 21, 21);">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;">function</span> myClientButton_onclick() {<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>document.getElementById(<span style="color: rgb(163, 21, 21);">'btn1'</span>).click();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span>}<o:p></o:p></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Courier New";"><span style=""> </span><span style="color: blue;"></</span><span style="color: rgb(163, 21, 21);">script</span><span style="color: blue;">><o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style="font-size: 10pt; font-family: "Courier New";"><span style=""> </span><span style="color: blue;"><</span><span style="color: rgb(163, 21, 21);">asp</span><span style="color: blue;">:</span><span style="color: rgb(163, 21, 21);">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="btn1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="Original"</span> <span style="color: red;">OnClientClick</span><span style="color: blue;">="alert('abc')"</span> <span style="color: red;">onclick</span><span style="color: blue;">="btn1_Click"</span> <span style="color: blue;">/><o:p></o:p></span></span></p> <p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: "Courier New";"><span style=""> </span><span style="color: blue;"><</span><span style="color: rgb(163, 21, 21);">input</span> <span style="color: red;">id</span><span style="color: blue;">="myClientButton"</span> <span style="color: red;">type</span><span style="color: blue;">="button"</span> <span style="color: red;">value</span><span style="color: blue;">="Press Me"</span> <span style="color: red;">onclick</span><span style="color: blue;">="return myClientButton_onclick()"</span> <span style="color: blue;">/></span></span></p> <asp:button id="btn1" runat="server" text="Original" onclientclick="alert('abc')" onclick="btn1_Click">Note that the HTML DOM click() method also raises btn1's OnClientClick event.</asp:button>Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-35919345826651139012009-06-10T16:34:00.000-04:002009-06-10T16:40:11.764-04:00FindControlByIDWhen we want to find a control by its ID, chances are it is usually nested in many levels. In this scenario, we need more powerful method than the .NET framework provided Control.FindControl.<br /><br />Writing such a method actually is straightforward enough:<br /><br /> private static Control FindControlByID(Control root, string id)<br /> {<br /> if (id == string.Empty)<br /> return null;<br /><br /> if (root.ID == id)<br /> return root;<br /><br /> foreach (Control c in root.Controls)<br /> {<br /> Control t = FindControlByID(c, id);<br /> if (t != null)<br /> {<br /> return t;<br /> }<br /> }<br /> return null;<br /> }<br /><br />It works great no matter there is master page involved or not; no matter how many levels the control hierarchy has.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-15480332627573985432009-06-02T10:29:00.000-04:002009-06-02T10:40:33.690-04:00Using Validator as a LabelOccasionally, we have several validation logic and for some of them we use the validators ASP.NET provides and for some of them we may want to write our own code and have a label displaying the error message. As we know, a validator control has a label to display its error message. By using the validator's label, we can save a label control and more importantly, it may be easier for the layout. (This may not be a good practice since we are letting the validator doing some work it is not supposed to do. I want to log it anyway since sometimes this can be handy)<br /><br />In our own logic, if we want to use the RequireFieldsValidator's (rfvVersion) build-in label to display our custom error message, we can write:<br /><br />rfvVersion.IsValid = false;<br />rfvVersion.Text = "Incorrect Format";<br />rfvVersion.Enabled = true;Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-39118588243376216122009-05-27T13:01:00.000-04:002009-05-27T13:11:33.939-04:00Enumerating enumProbably all of us have encountered the situation where we need to enumerating a enum type. For example, we may want to put all the enum values in a listbox. The solution may not be so straight forward to come up with, but is simple enough: (RegistryValueKind is an enum type in Microsoft.Win32 namespace)<br /><br /><!--[endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]--> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >List</span><span style=";font-family:";font-size:10;" ><<span style="color:blue;">string</span>> list = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">List</span><<span style="color:blue;">string</span>>();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;color:blue;" >foreach</span><span style=";font-family:";font-size:10;" >( <span style="color: rgb(43, 145, 175);">RegistryValueKind</span> kind <span style="color:blue;">in<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span>Enum</span><span style=";font-family:";font-size:10;" >.GetValues(</span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style="color:blue;">typeof</span>(<span style="color: rgb(43, 145, 175);">RegistryValueKind</span>)).Cast<<span style="color: rgb(43, 145, 175);">RegistryValueKind</span>>())<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" >{<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span>list.Add(kind.ToString() + ((<span style="color:blue;">int</span>)kind).ToString());<o:p></o:p></span></p> <p class="MsoNormal"><span style="line-height: 115%;font-family:";font-size:10;" >}</span></p> <string><string><registryvaluekind><br /></registryvaluekind></string></string>Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-61465072218962253762009-05-04T17:46:00.000-04:002009-05-04T17:59:48.429-04:00Accessing Data Bound to ListViewIf we try to access data that are bound to listview by the following code:<br />ListViewDataItem lvDataItem = ListView.Item[index];<br /><br />We'll find that lvDataItem is null.<br /><br />In fact, all the ListViewDataItem in listview's Item collection are null. The only time it is not null is in ItemDataBound event of ListView. I guess it is designed this way to save memory space. So what if we need to access the data outside ItemDataBound event?<br /><br />The answer is simple. Just specify DataKeyNames property of ListView like this:<br />DataKeyNames="ProductName, UnitPrice"<br /><br />Then, we can access any data:<br />ListView.DataKeys[index]["ProductName"]Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com1tag:blogger.com,1999:blog-9153561184848277923.post-65055966793633167432009-05-01T09:27:00.000-04:002009-09-02T14:49:58.956-04:00Javascript Code Meets Postback(full and partial)Code in $(document).ready is NOT executed in partial postback; pageLoad() function works for partial postback. Both work in full(standard postback).<br /><br />For the javascript code register in ClientScript.RegisterClientScriptBlock, it is on the page for both full and partial postback. (Because in partial postback, Page_Load event on server side also gets called.) <br /><br />http://encosia.com/2009/03/25/document-ready-and-pageload-are-not-the-same/Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-61286963079922992672009-04-27T09:23:00.000-04:002009-04-27T09:30:47.072-04:00Restoring master and msdb DatabaseRestoring master database requires sql server running in single-user mode. We can do the following:<br />1. Start a cmd window<br />2. Stop SQL Server<br />net stop mssqlserver<br />3. Start SQL Server in single user mode<br />sqlservr -m<br />4. Start another cmd window<br />5. Restore the master database<br />osql -E -Q"restore database master from disk = 'D:\SQL2000\MSSQL\BACKUP\master-2007-03-12.bak'<br /><br />NOTE: after executing this command you should see the following output:<br />The master database has been successfully restored. Shutting down SQL Server.<br />SQL Server is terminating this process.<br /><br />In step 5, we can also restore the database in Query Analyzer by running: restore database master from disk = 'D:\SQL2000\MSSQL\BACKUP\master-2007-03-12.bak'<br /><br /><br />To restore msdb database, we should run sql server in multi-user mode. If there is an error indicating exclusive access, then try to stop sqlserveragent.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-85429740985562023212009-04-10T10:40:00.000-04:002009-04-10T10:44:48.450-04:00Color of Source Code in Blog<!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:View> <w:zoom>0</w:Zoom> <w:trackmoves/> <w:trackformatting/> <w:punctuationkerning/> <w:validateagainstschemas/> <w:saveifxmlinvalid>false</w:SaveIfXMLInvalid> <w:ignoremixedcontent>false</w:IgnoreMixedContent> <w:alwaysshowplaceholdertext>false</w:AlwaysShowPlaceholderText> <w:donotpromoteqf/> <w:lidthemeother>EN-US</w:LidThemeOther> <w:lidthemeasian>X-NONE</w:LidThemeAsian> <w:lidthemecomplexscript>X-NONE</w:LidThemeComplexScript> <w:compatibility> <w:breakwrappedtables/> <w:snaptogridincell/> <w:wraptextwithpunct/> <w:useasianbreakrules/> <w:dontgrowautofit/> <w:splitpgbreakandparamark/> <w:dontvertaligncellwithsp/> <w:dontbreakconstrainedforcedtables/> <w:dontvertalignintxbx/> <w:word11kerningpairs/> <w:cachedcolbalance/> </w:Compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathpr> <m:mathfont val="Cambria Math"> <m:brkbin val="before"> <m:brkbinsub val="--"> <m:smallfrac val="off"> <m:dispdef/> <m:lmargin val="0"> <m:rmargin val="0"> <m:defjc val="centerGroup"> <m:wrapindent val="1440"> <m:intlim val="subSup"> <m:narylim val="undOvr"> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:latentstyles deflockedstate="false" defunhidewhenused="true" defsemihidden="true" defqformat="false" defpriority="99" latentstylecount="267"> <w:lsdexception locked="false" priority="0" semihidden="false" unhidewhenused="false" qformat="true" name="Normal"> <w:lsdexception locked="false" priority="9" semihidden="false" unhidewhenused="false" qformat="true" name="heading 1"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 2"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 3"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 4"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 5"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 6"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 7"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 8"> <w:lsdexception locked="false" priority="9" qformat="true" name="heading 9"> <w:lsdexception locked="false" priority="39" name="toc 1"> <w:lsdexception locked="false" priority="39" name="toc 2"> <w:lsdexception locked="false" priority="39" name="toc 3"> <w:lsdexception locked="false" priority="39" name="toc 4"> <w:lsdexception locked="false" priority="39" name="toc 5"> <w:lsdexception locked="false" priority="39" name="toc 6"> <w:lsdexception locked="false" priority="39" name="toc 7"> <w:lsdexception locked="false" priority="39" name="toc 8"> <w:lsdexception locked="false" priority="39" name="toc 9"> <w:lsdexception locked="false" priority="35" qformat="true" name="caption"> <w:lsdexception locked="false" priority="10" semihidden="false" unhidewhenused="false" qformat="true" name="Title"> <w:lsdexception locked="false" priority="1" name="Default Paragraph Font"> <w:lsdexception locked="false" priority="11" semihidden="false" unhidewhenused="false" qformat="true" name="Subtitle"> <w:lsdexception locked="false" priority="22" semihidden="false" unhidewhenused="false" qformat="true" name="Strong"> <w:lsdexception locked="false" priority="20" semihidden="false" unhidewhenused="false" qformat="true" name="Emphasis"> <w:lsdexception locked="false" priority="59" semihidden="false" unhidewhenused="false" name="Table Grid"> <w:lsdexception locked="false" unhidewhenused="false" name="Placeholder Text"> <w:lsdexception locked="false" priority="1" semihidden="false" unhidewhenused="false" qformat="true" name="No Spacing"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 1"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 1"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 1"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 1"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 1"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 1"> <w:lsdexception locked="false" unhidewhenused="false" name="Revision"> <w:lsdexception locked="false" priority="34" semihidden="false" unhidewhenused="false" qformat="true" name="List Paragraph"> <w:lsdexception locked="false" priority="29" semihidden="false" unhidewhenused="false" qformat="true" name="Quote"> <w:lsdexception locked="false" priority="30" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Quote"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 1"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 1"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 1"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 1"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 1"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 1"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 1"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 1"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 2"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 2"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 2"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 2"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 2"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 2"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 2"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 2"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 2"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 2"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 2"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 2"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 2"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 2"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 3"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 3"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 3"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 3"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 3"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 3"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 3"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 3"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 3"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 3"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 3"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 3"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 3"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 3"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 4"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 4"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 4"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 4"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 4"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 4"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 4"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 4"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 4"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 4"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 4"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 4"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 4"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 4"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 5"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 5"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 5"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 5"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 5"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 5"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 5"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 5"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 5"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 5"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 5"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 5"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 5"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 5"> <w:lsdexception locked="false" priority="60" semihidden="false" unhidewhenused="false" name="Light Shading Accent 6"> <w:lsdexception locked="false" priority="61" semihidden="false" unhidewhenused="false" name="Light List Accent 6"> <w:lsdexception locked="false" priority="62" semihidden="false" unhidewhenused="false" name="Light Grid Accent 6"> <w:lsdexception locked="false" priority="63" semihidden="false" unhidewhenused="false" name="Medium Shading 1 Accent 6"> <w:lsdexception locked="false" priority="64" semihidden="false" unhidewhenused="false" name="Medium Shading 2 Accent 6"> <w:lsdexception locked="false" priority="65" semihidden="false" unhidewhenused="false" name="Medium List 1 Accent 6"> <w:lsdexception locked="false" priority="66" semihidden="false" unhidewhenused="false" name="Medium List 2 Accent 6"> <w:lsdexception locked="false" priority="67" semihidden="false" unhidewhenused="false" name="Medium Grid 1 Accent 6"> <w:lsdexception locked="false" priority="68" semihidden="false" unhidewhenused="false" name="Medium Grid 2 Accent 6"> <w:lsdexception locked="false" priority="69" semihidden="false" unhidewhenused="false" name="Medium Grid 3 Accent 6"> <w:lsdexception locked="false" priority="70" semihidden="false" unhidewhenused="false" name="Dark List Accent 6"> <w:lsdexception locked="false" priority="71" semihidden="false" unhidewhenused="false" name="Colorful Shading Accent 6"> <w:lsdexception locked="false" priority="72" semihidden="false" unhidewhenused="false" name="Colorful List Accent 6"> <w:lsdexception locked="false" priority="73" semihidden="false" unhidewhenused="false" name="Colorful Grid Accent 6"> <w:lsdexception locked="false" priority="19" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Emphasis"> <w:lsdexception locked="false" priority="21" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Emphasis"> <w:lsdexception locked="false" priority="31" semihidden="false" unhidewhenused="false" qformat="true" name="Subtle Reference"> <w:lsdexception locked="false" priority="32" semihidden="false" unhidewhenused="false" qformat="true" name="Intense Reference"> <w:lsdexception locked="false" priority="33" semihidden="false" unhidewhenused="false" qformat="true" name="Book Title"> <w:lsdexception locked="false" priority="37" name="Bibliography"> <w:lsdexception locked="false" priority="39" qformat="true" name="TOC Heading"> </w:LatentStyles> </xml><![endif]--><style> <!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1610611985 1073750139 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin-top:0in; margin-right:0in; margin-bottom:10.0pt; margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:Calibri; mso-fareast-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} .MsoPapDefault {mso-style-type:export-only; margin-bottom:10.0pt; line-height:115%;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} </style> <![endif]-->Paste the code in Word, copy it from there and paste here (in Compose mode). Then we'll have the source code color preserved!<br /><br /><br /><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span><span style="color:blue;">function</span> sayAlice() {<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span><span style="color:blue;">var</span> sayAlert = <span style="color:blue;">function</span>() { alert(alice); }<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span><span style="color:green;">// Local variable that ends up within closure<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span><span style="color:blue;">var</span> alice = <span style="color: rgb(163, 21, 21);">'Hello Alice'</span>;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;"><span style=";font-family:";font-size:10;" ><span style=""> </span><span style="color:blue;">return</span> sayAlert;<o:p></o:p></span></p> <p class="MsoNormal"><span style="line-height: 115%;font-family:";font-size:10;" ><span style=""> </span>}</span></p>Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-64149301531615660432009-03-24T17:03:00.000-04:002009-03-24T17:19:14.906-04:00javascript code not working when using updatepanel?I have some javascript code gets executed when window.onload is fired. It basically modifies the appearance of my server controls. Everything works fine before I placed my server controls in an updatePanel(ASP.NET).<br /><br />When the page got partially rendered(i.e. I clicked the button which is inside the updatePanel to cause a postback), the javascript code didn't work anymore.<br /><br />I haven't delve into this issue to completely understand this, but I found a solution. It is to use PageRequestManager to register the javascript function I'd like to call each time there is a postback(async or sync). The code is: <br />function load() {<br />Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(javascriptFuncName);<br />}<br />Then add onload="load()" to body tag.<br /><br />For reference:http://msdn.microsoft.com/en-us/library/bb311028.aspx(Sys.WebForms.PageRequestManager Class)Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com2tag:blogger.com,1999:blog-9153561184848277923.post-37670017676992612912009-03-18T14:54:00.000-04:002009-03-18T14:58:10.351-04:00Web page gets messy in IE6<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVZ2t0WabM7BbJwsuuAc5BLvC7VIQq8lp60XFCjcgqmC2UB2_4bvNnLEiZyWDLZyVaPlvDMEv1NQAj6-JtzbavBsPNxoXBFWoNhIR756xVXWx8zaWs2NaKFrLUKBn2WGWTPahfDvflrzo/s1600-h/messy.JPG"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 246px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVZ2t0WabM7BbJwsuuAc5BLvC7VIQq8lp60XFCjcgqmC2UB2_4bvNnLEiZyWDLZyVaPlvDMEv1NQAj6-JtzbavBsPNxoXBFWoNhIR756xVXWx8zaWs2NaKFrLUKBn2WGWTPahfDvflrzo/s320/messy.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5314604075405808130" /></a><br /><br />The problem: Using background inside frames.<br />The solution: Use img instead of background and set its z-index properly.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-16791040473489815762009-03-18T10:53:00.000-04:002009-03-18T10:58:24.474-04:00Setup IIS for ASP.NET projects1. Make sure .Net Framework and IIS are installed.<br />2. Register ASP.NET with IIS by executing ASPNET_REGIIS.EXE -i Use the one from version 2.0 (i.e. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727) <br />3. Make sure ASP.NET 2.0 is the default framework: <br /> 1)Open IIS <br /> 2)Right-click on the default web site and click 'properties'. <br /> 3)Click on the ASP.NET tab. <br /> 4)Select ASP.NET 2.0 as the default version. <br /> 5)Repeat for the target web virtual directory<br />4. Click on Web Service Extensions and mark ASP.NET v2.0.50727 as 'allowed'. (For IIS 5.1, ignore this)<br />5. Right Click on the virtual directory - select properties and then click on "Create" next to the "Application" Label and the textbox. It will automatically create the "application" using the virtual directory's name. Now the application can be accessed.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-30902509647448510592009-03-15T13:39:00.000-04:002009-03-15T13:43:28.800-04:00Coninental ticket number on eTicket Boarding PassMy eTicket has 14 digits while the ticket number of Continental is 13 digits which starts with 005. Just ignore the damn last digit.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-45908453089580454892009-03-10T11:51:00.000-04:002009-03-10T12:11:09.435-04:00Making a table scrollableThe whole point is to make an html table(asp.net table or whatever is rendered as an html one) sitting inside a div element that has overflow attribute set to "auto" or "scroll".<br /><br />For example:<br /> <div style="border-style: solid; overflow: scroll; height: 100px; width: 100px;"><br /><br /> <asp:table id="table" runat="server" borderwidth="1px" width="100%"><br /><br /> </asp:table></div><br /><br />asp:Panel is render as div, we can also use it:<br /><br /> <asp:panel id="pl2" runat="server" height="100px" width="50%" cssclass="overflow"><br /> <table border="1" width="100%"><br /><br /> <tbody><tr><td>stuff</td><br /><br /> <td>more stuff</td></tr><br /><br /> <tr><td>stuff</td><br /><br /> <td>more stuff</td></tr><br /><br /> <tr><td>stuff</td><br /><br /> <td>more stuff</td></tr><br /><br /> <tr><td>stuff</td><br /><br /> <td>more stuff</td></tr><br /><br /> <tr><td>stuff</td><br /><br /> <td>more stuff</td></tr><br /><br /> </tbody></table><br /> </asp:panel><br /><br />Just aware that we need to set the "CssClass" attribute for asp:Panel (not "Style", not "overflow"). Same technique should be able to make other control scrollable (e.g. GridView).Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-51784284979418566512008-09-07T13:48:00.000-04:002008-09-07T13:55:15.979-04:00Making Tomcat Support JSF1. Download the latest version of the JSF Reference Implementation from <a href="http://java.sun.com/j2ee/javaserverfaces/download.html">http://java.sun.com/j2ee/javaserverfaces/download.html</a><br /><br />2. Unzip the downloaded file. Copy all JAR files files from the <tt>lib</tt> subdirectory of JSF unzipped folder to the <tt>lib</tt> subdirectory of Tomcat. (At the time of writing, they are <tt>jsf-api.jar</tt><tt> jsf-impl.jar</tt>)<br /><br />3. Copy the following two JAR files from the <tt>webapps/examples/WEB-INF/lib</tt> subdirectory of Tomcat installation to the <tt>lib</tt> subdirectory of Tomcat<br /><ul><li><tt>jstl.jar</tt></li><li><tt>standard.jar</tt></li></ul>Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com0tag:blogger.com,1999:blog-9153561184848277923.post-71755157101775970952008-08-20T14:02:00.000-04:002008-08-20T14:29:56.562-04:00Show Ellipsis Text in GridViewprotected void Page_Load(object sender, EventArgs e)<br /> {<br /> // ... ...<br /> gv1.Style["TABLE-LAYOUT"] = "fixed";<br /> }<br /><br /> protected void gv1_RowCreated(object sender, GridViewRowEventArgs e)<br /> {<br /> foreach (TableCell cell in e.Row.Cells)<br /> {<br /> cell.Wrap = false;<br /> cell.Style["overflow"] = "hidden";<br /> cell.Style["text-overflow"] = "ellipsis";<br /> }<br /> }<br /><br /> // Showing full text tooltip in each cell<br /> protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)<br /> {<br /> foreach (TableCell cell in e.Row.Cells)<br /> {<br /> cell.ToolTip = cell.Text;<br /> }<br /> }<br /><br />The above code just shows what style settings need to be set for the ellipsis effect. It is not recommended to write product code like this. Keep in mind that<br />gv1.Style["TABLE-LAYOUT"] = "fixed";<br />actually sets "TABLE-LAYOUT" style property of HTML Table. Therefore, this should be done in a CSS file: not only to separate UI part from logic part, but to make the data travel between server and client much light-weighted. (To demonstrate the last part, look at the source of the rendered HTML to see the table cell styles are duplicated across all the tags.)Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com2tag:blogger.com,1999:blog-9153561184848277923.post-23604035354006455482008-08-18T11:47:00.000-04:002008-09-04T15:50:03.913-04:00Register Custom Control in Web PageWhen we want to use a User Control (which is defined in *.ascx) in a web page, we can register the control like this:<br /><%@ Register Src="~/MyObjectDisplayer.ascx" TagName="MOD" TagPrefix="CustomControl" %><br /><br />If we use a Custom Control (which is defined in *.cs), however, the register tag should be a little different:<br /><%@ Register Namespace="MyControls" TagPrefix="CustomControl" %><br /><br />Whenever we want to place this control in the webpage, we write:<br /><CustomControl:PromptButton id="pb1" runat="server"/><br /><br />It assumes that our control classes is PromptButton and it is in MyControls namespace. And note that it has been tested in ASP.NET Web Site project, but not in ASP.NET Web Application project.Xiaoguanghttp://www.blogger.com/profile/08509314968024808841noreply@blogger.com1