アットウィキロゴ
ASP.NET
業務日誌.NET
スタイルシートファイルをページに設定する(Visual Studio 2008)

スタイルシートの設定を.cssのファイルにして、ページのHeadで取り込む方法
外部ファイルの記述
1.ソリューションエクスプローラ -> スタイルシートファイル選択
2.ページのデザイン画面にドラッグ&ドロップ

元ネタ
category: miscellaneous
http://d.hatena.ne.jp/frontline/20080417/p3


2008/07/05メモ
SQL Server
日付の書式設定
日付をyyyy/mm/dd形式で表示
CONVERT(VARCHAR(10), GetDate(), 111)



既存のWebアプリをAjax対応にする際の注意点
既存のWebアプリをAjax対応しようとしたらエラーが出た「'Sys'は宣言されていません」
探したらここが参考になった
http://natchan-develop.seesaa.net/archives/200704-1.html
http://www.atmostalfa.com/wp/?p=34
とりあえずWeb.Configに以下を追加で動きます
具体的にはこれ
1.configSectionタグ
<configuration>
 <configSections>
   <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
     <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
         <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
       <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
         <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
         <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
         <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
       </sectionGroup>
     </sectionGroup>
   </sectionGroup>
 </configSections>

2.system.webタグ内の項目
 ・pagesタグ内のcontrolsタグ
 ・httpHandlersタグ
 ・httpModulesタグ
<configuration>
 <system.web>
   <pages>
     
     <controls>
       <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     </controls>
     
   </pages>
   
   <httpHandlers>
     <remove verb="*" path="*.asmx"/>
     <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
   </httpHandlers>

   <httpModules>
     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </httpModules>

3.system.webServerタグ
<configuration>

 <system.webServer>
   <validation validateIntegratedModeConfiguration="false"/>
   <modules>
     <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
   </modules>
   <handlers>
     <remove name="WebServiceHandlerFactory-Integrated" />
     <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
          type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
          type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
     <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   </handlers>
 </system.webServer>

なぜか1でrequirePermissionが設定されているとエラーとなるので、除外して動いた。


VisualStudio2005
ショートカット
 コードエディタ
  ・メソッド定義場所へ移動    メソッドを選択 -> F12
  ・選択範囲のコメントアウト   [Ctrl] + K + C
  ・  〃  コメントアウト解除 [Ctrl] + K + U
 デバッグ
  ・ステップイン         F11
  ・ステップオーバー       F11 + Shift


2008/07/06メモ
C#
文字列がnullまたは空文字か調べる
if ( !String.IsNullOrEmpty(checkString) ) {
   // 値がある場合
} else {
   // null または 空文字の場合
}


bat,cmd
サブディレクトリ以下にあるテキストファイル一覧を取得
dir /b /s *.txt


2008/07/20メモ
CSS
テーブル内の垂直(縦)方向の位置設定
vertical-align
項目
セル内 baseline, top, bottom, middle



2008/10/13
SQLServer
■smalldatetimeにInsert
INSERT INTO SAMPLE_TABLE VALUES (
  CONVERT(smalldatetime, '08/01/23')
)


2008/10/27
■日付より指定した部分を取得したい
DATEPART(取得したい部分, 対象の日付)

  • 取得したい部分一覧
指定部分     指定名    省略名  
年        year     yy, yyyy 
         quarter    qq, q  
月        month     mm, m  
年内の経過日数  dayofyear   dy, y  
日        day      dd, d  
週        week     wk, ww  
曜日(1~7、1=日) weekday    dw    
時間       hour     hh    
分        minute    mi, n  
秒        second    ss, s  
ミリ秒      millisecond  ms    
DATEPART(day, GETDATE())

2008/11/09
SQLServer
■日付より指定した部分を取得したい2
日付関数(日付)
関数名
YEAR
MONTH
DAY
select YEAR(GETDATE());  // "2008"と表示



2008/11/03
HTML
■テーブルの縦、横を結合したい
  • 縦のセルを結合
 rowspan
<table>
  <tr>
    <td rowspan="2">1-1,2-1</td>
    <td>1-2</td>
  </tr>
  <tr>
    <td>2-2</td>
  </tr>
</table>

  • 横のセルを結合
 colspan
<table>
  <tr>
    <td colspan="2">1-1,1-2</td>
  </tr>
  <tr>
    <td>2-1</td>
    <td>2-2</td>
  </tr>
</table>


2008/12/06メモ
C#
■コントロール「カレンダー」のクリックした際の日付のフォーマットを変更
  • 通常の場合("yyyy/mm/dd hhMMss"で表示)
string calDataStr = this.Calendar1.SelectedDate.ToString();
// 2008/01/23 0:00:00

  • yyyy/mm/ddと表示
string calDataStr = this.Calendar1.SelectedDate.ToShortDateString();
// 2008/01/23

  • 年月日を漢字で表示
string calDataStr = this.Calendar1.SelectedDate.ToLongDateString();
// 2008年1月23日


2009/02/06メモ
Oracle
■SQLPlusの実行結果をファイル出力
  • 通常のファイル出力 (C:\Test\list.lstというファイル名で保存)
SQL> spool C:\Test\list
SQL> select * from table;
    ・
    ・
    ・
SQL> spool off

  • CSVファイル出力 (可変対応)
SQL> set echo off
SQL> set linesize 1000
SQL> set pagesize 0
SQL> set trimspool on
SQL> set feedback off
SQL> set colsep ','
SQL> spool C:\Test\list.csv
SQL> select id ||','|| name ||','|| cmnt from table;
    ・
    ・
    ・
SQL> spool off
コマンド説明
set echo off コンソールメッセージ非表示
set linesize 1000 1レコードの表示数
set pagesize 0 数レコード間のセパレータ非表示
set trimspool on 各行の行末スペース削除
set feedback off 「~行が選択されました」非表示
set colsep ',' カラム間の区切り文字指定(カンマ','にする)

参考サイト
忘れっぽいエンジニアのオラクルSQLリファレンス
http://oracle.se-free.com/utl/C1_csv.html
Bash
http://homepage2.nifty.com/BASH/oracle/sqlplus_tech.html



2009/11/19メモ
VisualStudio
■スタートページの最近使ったプロジェクトを削除
regeditを起動し
「HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList」の
「File1」~「File18」を削除

参考サイト
使えないプログラマー
http://tukaenai-pg.cocolog-nifty.com/blog/
VisualStudio2005 最近使ったプロジェクトを削除
http://tukaenai-pg.cocolog-nifty.com/blog/2006/06/visualstudio200_78bb.html


2010/02/17
SQLServer
日付を連続で指定する(サンプル)
ALTER procedure [dbo].[getRangeDate]
as
begin
    
    declare @dateFrom datetime
    declare @dateTo datetime
    
    create table #calendar
    (date datetime primary key)
    
    --set @dateFrom = convert(nvarchar(10), getdate(), 111)
    --set @dateTo = convert(nvarchar(10), getdate()+10, 111)
    set @dateFrom = '2009/07/01'
    set @dateTo = '2009/07/30'
    
    while @dateFrom <= @dateTo
    begin
        insert into #calendar (date)
        values (@dateFrom)
        set @dateFrom = @dateFrom + 1
    end
    
    select 
        *
    from 
        #calendar a
    left join test3 b on convert(nvarchar(10), b.date, 111) = convert(nvarchar(10), a.date, 111)
    
    return
end


2010/03/11
ASP.NET C#
web.configの項目を取得(configuration/appSettings内)

web.config
<?xml version="1.0"?>
<configuration>
	<appSettings>
		<add key="LogPath" value="C:\App\Log\"/>
	</appSettings>
</configuration>

ソース
System.Web.Configuration.WebConfigurationManager.AppSettings["LogPath"].ToString();



2010/05/24
HTML/CSS
tableでのセル結合時の列幅調整

テーブルの幅をpx指定し、tdタグの幅を%指定にすればOK
<table style="width:800px;">
  <tr>
    <td>a</td>
    <td colspan="2" style="width:60%;">bc</td>
  </tr>
  <tr>
    <td>a</td>
    <td>b</td>
    <td>c</td>
  </tr>
</table>
参考サイト
CSSサンプルプログ
http://css-el.seesaa.net/article/149878339.html



2010/06/17
ASP.NET C#
無名delegateの使用例

List<TestEntity> entities が存在し、中に複数のTestEntityが入っているとする場合に
entitiesから指定したIDのTestEntityを取得する
int targetTestId = 10;
TestEntity entity = entities.Find(delegate(TestEntity tempEntity) { return tempEntity.TestId == targetTestId; });



2012/08/29
Postgre
テーブル名 カラム名の取得SQL

select  table_name,column_name
from    information_schema.columns 
where   table_catalog='データベース名'
and     table_schema = 'public'
order by
        table_name,ordinal_position;

参考サイト
いろいろ備忘録日記
http://d.hatena.ne.jp/gsf_zero1/20080226/p1



2012/08/29
Postgre
カラム名の変更SQL

ALTER TABLE テーブル名 RENAME COLUMN 変更前カラム名 TO 変更後カラム名;

参考サイト
PostgreSQL 7.3.2 ユーザガイド
http://www.postgresql.jp/document/pg732doc/user/ddl-alter.html]]



2012/09/25
Postgre
現在日時取得SQL

基本的に「clock_timestamp()」をよく使うかな?

transaction_timestamp() -- トランザクション開始日時を取得(ストアドとか別でも同じ日時)
statement_timestamp() -- サーバへリクエスト受付日時を取得(同じSQL内なら同じ日時)
clock_timestamp() -- システム日付を取得(SQLServer getdate() に相当)

参考サイト
yehara のはてな日記
http://d.hatena.ne.jp/gsf_zero1/20080226/p1
最終更新:2012年09月25日 15:15