mmlt;body onContextMenu="return false" onDragStart="return false" onSelectStart="return false"mmgt;
protected void BasePage_PreRender( object sender, System.EventArgs e )
{
RegisterClientScript();
DisableMouseDragging();
}
1.// (c) 2001 Microsoft Corporation
2. function AddDefaultServerScriptToWizard(selProj)
3. {
4. wizard.AddSymbol("DEFAULT_SERVER_SCRIPT", "JavaScript");
5. }
6.
7. function AddDefaultClientScriptToWizard(selProj)
8. {
9. var prjScriptLang = selProj.Properties("DefaultClientScript").Value;
10. // 0 = JScript
11. // 1 = VBScript
12. if(prjScriptLang == 0)
13. {
14. wizard.AddSymbol("DEFAULT_CLIENT_SCRIPT", "JavaScript");
15. }
16. else
17. {
18. wizard.AddSymbol("DEFAULT_CLIENT_SCRIPT", "VBScript");
19. }
20. }
21.
22. function AddDefaultDefaultHTMLPageLayoutToWizard(selProj)
23. {
24. var prjPageLayout = selProj.Properties("DefaultHTMLPageLayout").Value;
25. // 0 = FlowLayout
26. // 1 = GridLayout
27. if(prjPageLayout == 0)
28. {
29. wizard.AddSymbol("DEFAULT_HTML_LAYOUT", "FlowLayout");
30. }
31. else
32. {
33. wizard.AddSymbol("DEFAULT_HTML_LAYOUT", "GridLayout");
34. }
35. }
36.
37. function OnFinish(selProj, selObj)
38. {
39. var oldSuppressUIValue = true;
40. try
41. {
42. oldSuppressUIValue = dte.SuppressUI;
43. var strProjectName = wizard.FindSymbol("PROJECT_NAME");
44. var strSafeProjectName = CreateSafeName(strProjectName);
45. wizard.AddSymbol("SAFE_PROJECT_NAME", strSafeProjectName);
46. SetTargetFullPath(selObj);
47. var strProjectPath = wizard.FindSymbol("TARGET_FULLPATH");
48. var strTemplatePath = wizard.FindSymbol("TEMPLATES_PATH");
49.
50. var strTpl = "";
51. var strName = "";
52. var InfFile = CreateInfFile();
53.
54. // add the default project props for the aspx file before we
55. // render it
56. AddDefaultServerScriptToWizard(selProj);
57. AddDefaultClientScriptToWizard(selProj);
58. AddDefaultTargetSchemaToWizard(selProj);
59. AddDefaultDefaultHTMLPageLayoutToWizard(selProj);
60.
61. // render our file
62. AddFilesToProject(selObj, strProjectName,
63. strProjectPath, InfFile, true);
64.
65. AddReferencesForWebForm(selProj);
66. }
67. catch(e)
68. {
69. if( e.description.length > 0 )
70. SetErrorInfo(e);
71. return e.number;
72. }
73. finally
74. {
75. dte.SuppressUI = oldSuppressUIValue;
76. if( InfFile )
77. InfFile.Delete();
78. }
79. }
80.
81. // Make sure that the names of the files mentioned here match with
// that physically present in the folder
82. function SetFileProperties(oFileItem, strFileName)
83. {
84. if(strFileName == "WebForm1.aspx")
85. {
86. oFileItem.Properties("SubType").Value = "Form";
87. }
88.
89. if(strFileName == "WebForm1.aspx.cs")
90. {
91. oFileItem.Properties("SubType").Value = "Code";
92. }
93. }
94.
95. function AddFilesToProject(oProj, strProjectName,
96. strProjectPath, InfFile, AddItemFile)
97. {
98. try
99. {
100. dte.SuppressUI = false;
101. var projItems;
102.
103. projItems = oProj;
104.
105. var strTemplatePath = wizard.FindSymbol("TEMPLATES_PATH");
106.
107. var strTpl = "";
108. var strName = "";
109.
110. // if( Not a web project )
111. if(strProjectPath.charAt(strProjectPath.length - 1) != "\\")
112. strProjectPath += "\\";
113.
114. var strTextStream = InfFile.OpenAsTextStream(1, -2);
115. while (!strTextStream.AtEndOfStream)
116. {
117. strTpl = strTextStream.ReadLine();
118. if (strTpl != "")
119. {
120. strName = strTpl;
121. var strType = "";
122. if (strName == "WebForm1.aspx")
123. {
124. strType = "Form";
125. }
126. else // this would be code-behind file
127. {
128. strType = "Code";
129. }
130.
131. var strTarget = "";
132. var strFile = "";
133. strTarget = wizard.FindSymbol("ITEM_NAME");
134.
135. //if we are adding the code
136. //behind file, we need to append
137. //the .CS extension
138. //to the name obtained from the
139. //Add New Item dialog. this name would be
140. //something like "webform2.aspx"
141. if(strType == "Code")
142. {
143. strTarget = strTarget + ".cs";
144. }
145.
146. var fso;
147. fso = new
148. ActiveXObject("Scripting.FileSystemObject");
149. var TemporaryFolder = 2;
150. var tfolder = fso.GetSpecialFolder(TemporaryFolder);
151. var strTempFolder =
152. fso.GetAbsolutePathName(tfolder.Path);
153.
154. var strFile = strTempFolder + "\\" +
155. fso.GetTempName();
156. //var strFile = strTempFolder + "\\" + strTarget;
157.
158. var strClassName = strTarget.split(".");
159. wizard.AddSymbol("SAFE_CLASS_NAME", strClassName[0]);
160. wizard.AddSymbol("SAFE_ITEM_NAME", strClassName[0]);
161.
162. var strTemplate = strTemplatePath + "\\" + strTpl;
163. var bCopyOnly = false;
164. var strExt = strTpl.substr(strTpl.lastIndexOf("."));
165. if(strExt==".bmp" || strExt==".ico" ||
166. strExt==".gif" || strExt==".rtf"
167. || strExt==".css")
168. bCopyOnly = true;
169. wizard.RenderTemplate(strTemplate,
170. strFile, bCopyOnly, true);
171.
172. var projfile =
173. projItems.AddFromTemplate(strFile, strTarget);
174. SafeDeleteFile(fso, strFile);
175.
176. if(projfile)
177. SetFileProperties(projfile, strName);
178.
179. if(strType == "Form")
180. {
181. var window = projfile.Open(vsViewKindPrimary);
182. window.visible = true;
183. }
184.
185. //when adding the webform.aspx,
186. //the AddFromTemplate function called above
187. //automatically also adds the code-behind file.
188. //Since we want to add our file
189. //we will have to delete the file that
190. //was created by default before we
191. //create our custom code-behind file
192. if(strType == "Form")
193. {
194. var strTargetCS = strProjectPath
195. + strTarget + ".cs";
196. SafeDeleteFile(fso, strTargetCS)
197. }
198. }
199. }
200. strTextStream.Close();
201. }
202. catch(e)
203. {
204. strTextStream.Close();
205. throw e;
206. }
207. }
이전 글 : 엑셀 실무 활용노트(4) : N개의 데이터를 무작위로 추출하기
다음 글 : 인터넷 익스플로러에 나만의 버튼 만들기
최신 콘텐츠