Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1442 lines
37 KiB

  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. namespace UDDI.Web
  5. {
  6. public class UddiBrowser
  7. {
  8. public static bool IsNetscape6
  9. {
  10. get
  11. {
  12. return
  13. HttpContext.Current.Request.Browser.Type.StartsWith( "Netscape" ) &&
  14. HttpContext.Current.Request.Browser.MajorVersion >= 5;
  15. }
  16. }
  17. public static bool IsIE4
  18. {
  19. get
  20. {
  21. return
  22. HttpContext.Current.Request.Browser.Type.StartsWith( "IE" ) &&
  23. HttpContext.Current.Request.Browser.MajorVersion >= 4 &&
  24. HttpContext.Current.Request.Browser.MajorVersion < 5;
  25. }
  26. }
  27. public static bool IsIE5
  28. {
  29. get
  30. {
  31. return
  32. HttpContext.Current.Request.Browser.Type.StartsWith( "IE" ) &&
  33. HttpContext.Current.Request.Browser.MajorVersion >= 5;
  34. }
  35. }
  36. public static bool IsDownlevel
  37. {
  38. get { return !IsIE5; }
  39. }
  40. public static bool IsFrames
  41. {
  42. get{ return ( "true"==HttpContext.Current.Request[ "frames" ] );}
  43. }
  44. public static bool ShouldBeFrames
  45. {
  46. get{ return !IsDownlevel; }
  47. }
  48. }
  49. public class UddiPage : System.Web.UI.Page
  50. {
  51. private System.Web.UI.WebControls.PlaceHolder headerbag;
  52. public System.Web.UI.WebControls.PlaceHolder HeaderBag
  53. {
  54. get{ return headerbag; }
  55. set{ headerbag=(System.Web.UI.WebControls.PlaceHolder) value; }
  56. }
  57. private System.Web.UI.WebControls.PlaceHolder footerbag;
  58. public System.Web.UI.WebControls.PlaceHolder FooterBag
  59. {
  60. get{ return footerbag; }
  61. set{ footerbag=(System.Web.UI.WebControls.PlaceHolder) value; }
  62. }
  63. public bool IsDownlevel
  64. {
  65. get { return UddiBrowser.IsDownlevel; }
  66. }
  67. public bool EditMode
  68. {
  69. get
  70. {
  71. if( null == ViewState[ "EditMode" ] )
  72. return false;
  73. return (bool)ViewState[ "EditMode" ];
  74. }
  75. }
  76. public bool IsNetscape6
  77. {
  78. get { return UddiBrowser.IsNetscape6; }
  79. }
  80. public bool IsIE4
  81. {
  82. get { return UddiBrowser.IsIE4; }
  83. }
  84. public bool IsIE5
  85. {
  86. get { return UddiBrowser.IsIE5; }
  87. }
  88. private SytleSheetControlCollection stylesheets;
  89. public SytleSheetControlCollection StyleSheets
  90. {
  91. get
  92. {
  93. if( null==stylesheets )
  94. stylesheets = new SytleSheetControlCollection();
  95. return stylesheets;
  96. }
  97. set { stylesheets = (SytleSheetControlCollection)value; }
  98. }
  99. private PageStyleControl pagestyle = null;
  100. public PageStyleControl PageStyle
  101. {
  102. get
  103. {
  104. if( null==pagestyle )
  105. {
  106. pagestyle = PageStyleControl.GetDefault();
  107. }
  108. return pagestyle;
  109. }
  110. set { pagestyle = (PageStyleControl)value; }
  111. }
  112. private ClientScriptRegisterCollection clientscripts;
  113. public ClientScriptRegisterCollection ClientScript
  114. {
  115. get
  116. {
  117. if( null==clientscripts )
  118. clientscripts = new ClientScriptRegisterCollection();
  119. return clientscripts;
  120. }
  121. set{ clientscripts = (ClientScriptRegisterCollection)value; }
  122. }
  123. public string Root
  124. {
  125. get
  126. {
  127. if( "/" == Request.ApplicationPath )
  128. return "";
  129. return Request.ApplicationPath;
  130. }
  131. }
  132. public void CancelEditMode()
  133. {
  134. ViewState[ "EditMode" ] = false;
  135. }
  136. public void SetEditMode()
  137. {
  138. ViewState[ "EditMode" ] = true;
  139. }
  140. protected override void OnLoad( EventArgs e )
  141. {
  142. base.OnLoad( e );
  143. if( null!=HeaderBag )
  144. HeaderBag.Visible = PageStyle.ShowHeader;
  145. if( null!=FooterBag )
  146. FooterBag.Visible = PageStyle.ShowFooter;
  147. }
  148. protected override void Render( HtmlTextWriter output )
  149. {
  150. //
  151. // Render Open HTML
  152. //
  153. output.RenderBeginTag( HtmlTextWriterTag.Html );
  154. //
  155. // Render Open Head
  156. //
  157. output.Write( "<HEAD>\r\n" );
  158. //
  159. // Render StyleSheet Links
  160. //
  161. foreach( StyleSheetControl stylesheet in this.StyleSheets )
  162. stylesheet.RenderControl( output );
  163. //
  164. // Render Client Scripts
  165. //
  166. foreach( ClientScriptRegister script in this.ClientScript )
  167. script.RenderControl( output );
  168. if( null != PageStyle )
  169. {
  170. output.RenderBeginTag( HtmlTextWriterTag.Title );//<title>
  171. if( 0 == Config.GetInt( "Web.ServiceMode", 0 ) )
  172. {
  173. output.Write( UDDI.Localization.GetString( PageStyle.Title ) );
  174. }
  175. else
  176. {
  177. output.Write( UDDI.Localization.GetString( PageStyle.AltTitle ) );
  178. }
  179. output.RenderEndTag();//</title>
  180. }
  181. //
  182. // Render Close Head
  183. //
  184. output.Write( "</HEAD>\r\n" );
  185. //
  186. // Register the attributes for the body
  187. //
  188. if( null!=PageStyle )
  189. PageStyle.RenderControl( output );
  190. //
  191. // Render Open Body
  192. //
  193. output.RenderBeginTag( HtmlTextWriterTag.Body );
  194. //
  195. // Render Open Table.
  196. // This prevents scrolling problems.
  197. //
  198. if( null != PageStyle )
  199. output.AddAttribute( "border",PageStyle.BorderWidth );
  200. else
  201. output.AddAttribute( "border","0" );
  202. output.AddAttribute( "width","100%" );
  203. output.AddAttribute( "height","100%" );
  204. output.AddAttribute( "cellpadding","0" );
  205. output.AddAttribute( "cellspacing","0" );
  206. output.RenderBeginTag( HtmlTextWriterTag.Table );
  207. //
  208. // Render Open TR
  209. //
  210. if( UddiBrowser.IsDownlevel || UddiBrowser.IsNetscape6 )
  211. output.AddAttribute( "height","100%" );
  212. output.RenderBeginTag( HtmlTextWriterTag.Tr );
  213. //
  214. // Render Open TD
  215. //
  216. if( UddiBrowser.IsDownlevel || UddiBrowser.IsNetscape6 )
  217. output.AddAttribute( "height","100%" );
  218. output.AddAttribute( "valign","top" );
  219. output.RenderBeginTag( HtmlTextWriterTag.Td );
  220. //
  221. // Render Content of ASPX Page
  222. //
  223. base.Render( output );//do the base render
  224. //
  225. // Close All Open Tags
  226. //
  227. output.RenderEndTag();//td
  228. output.RenderEndTag();//tr
  229. output.RenderEndTag();//table
  230. output.RenderEndTag();//body
  231. output.RenderEndTag();//html
  232. }
  233. protected override void AddParsedSubObject( object obj )
  234. {
  235. if( obj is StyleSheetControl )
  236. {
  237. this.StyleSheets.Add( (StyleSheetControl)obj );
  238. return;
  239. }
  240. else if( obj is PageStyleControl )
  241. {
  242. this.PageStyle = (PageStyleControl)obj;
  243. return;
  244. }
  245. else if( obj is ClientScriptRegister )
  246. {
  247. this.ClientScript.Add( (ClientScriptRegister)obj );
  248. return;
  249. }
  250. base.AddParsedSubObject( obj );
  251. }
  252. }
  253. public class SytleSheetControlCollection : System.Collections.CollectionBase
  254. {
  255. public StyleSheetControl this[ int index ]
  256. {
  257. get{ return (StyleSheetControl)this.List[ index ]; }
  258. set{ this.List[ index ] = value; }
  259. }
  260. public int Add( StyleSheetControl control )
  261. {
  262. return this.List.Add( control );
  263. }
  264. public void Remove( int index )
  265. {
  266. this.RemoveAt( index );
  267. }
  268. public void Remove( StyleSheetControl control )
  269. {
  270. this.Remove( control );
  271. }
  272. public void Insert( int index, StyleSheetControl control )
  273. {
  274. this.List.Insert( index, control );
  275. }
  276. }
  277. public class StyleSheetControl : UddiControl, INamingContainer
  278. {
  279. public StyleSheetControl()
  280. {
  281. }
  282. private string defaultsheet;
  283. public string Default
  284. {
  285. get{ return defaultsheet; }
  286. set{ defaultsheet = value; }
  287. }
  288. private string downlevelsheet;
  289. public string DownLevel
  290. {
  291. get{ return downlevelsheet; }
  292. set{ downlevelsheet = value; }
  293. }
  294. protected override void Render( HtmlTextWriter output )
  295. {
  296. if( ( UddiBrowser.IsDownlevel && !UddiBrowser.IsNetscape6 ) && null!=DownLevel )
  297. {
  298. output.AddAttribute( HtmlTextWriterAttribute.Href, DownLevel );
  299. }
  300. else if( ( !UddiBrowser.IsDownlevel || UddiBrowser.IsNetscape6 ) && null!=Default )
  301. {
  302. output.AddAttribute( HtmlTextWriterAttribute.Href, Default );
  303. }
  304. else
  305. {
  306. return;
  307. }
  308. output.AddAttribute( "rel","stylesheet");
  309. output.AddAttribute( "type", "text/css" );
  310. output.RenderBeginTag( HtmlTextWriterTag.Link );
  311. output.RenderEndTag();
  312. }
  313. }
  314. public class PageStyleControl : UddiControl, INamingContainer
  315. {
  316. public PageStyleControl()
  317. {
  318. //
  319. // Show footer if Config value is set.
  320. //
  321. this.ShowFooter = ( Config.GetInt( "Web.ShowFooter",0 ) > 0 );
  322. //
  323. // Show header only if DownLevel
  324. //
  325. this.ShowHeader = !UddiBrowser.ShouldBeFrames;
  326. //
  327. // Set Page margin data
  328. //
  329. this.MarginHeight = "0";
  330. this.MarginWidth = "0";
  331. this.LeftMargin = "0";
  332. this.RightMargin = "0";
  333. this.TopMargin = "0";
  334. this.BottomMargin = "0";
  335. }
  336. private string title;
  337. public string Title
  338. {
  339. get{ return title; }
  340. set{ title=value; }
  341. }
  342. private string alttitle;
  343. public string AltTitle
  344. {
  345. get{ return alttitle; }
  346. set{ alttitle=value; }
  347. }
  348. private string oncontextmenu;
  349. public string OnClientContextMenu
  350. {
  351. get{ return oncontextmenu; }
  352. set{ oncontextmenu=value; }
  353. }
  354. private string leftmargin;
  355. public string LeftMargin
  356. {
  357. get{ return leftmargin; }
  358. set{ leftmargin=value; }
  359. }
  360. private string topmargin;
  361. public string TopMargin
  362. {
  363. get{ return topmargin; }
  364. set{ topmargin=value; }
  365. }
  366. private string bottommargin;
  367. public string BottomMargin
  368. {
  369. get{ return bottommargin; }
  370. set{ bottommargin=value; }
  371. }
  372. private string rightmargin;
  373. public string RightMargin
  374. {
  375. get{ return rightmargin; }
  376. set{ rightmargin=value;}
  377. }
  378. private string marginheight;
  379. public string MarginHeight
  380. {
  381. get{ return marginheight; }
  382. set{ marginheight=value; }
  383. }
  384. private string marginwidth;
  385. public string MarginWidth
  386. {
  387. get{ return marginwidth; }
  388. set{ marginwidth=value; }
  389. }
  390. private string onload;
  391. public string OnClientLoad
  392. {
  393. get{ return onload; }
  394. set{ onload=value; }
  395. }
  396. private string bgcolor;
  397. public string BackgroundColor
  398. {
  399. get{ return bgcolor; }
  400. set{ bgcolor=value; }
  401. }
  402. private string linkcolor;
  403. public string LinkColor
  404. {
  405. get{ return linkcolor; }
  406. set{ linkcolor=value; }
  407. }
  408. private string alinkcolor;
  409. public string ALinkColor
  410. {
  411. get{ return alinkcolor; }
  412. set{ alinkcolor=value; }
  413. }
  414. private string vlinkcolor;
  415. public string VLinkColor
  416. {
  417. get{ return vlinkcolor; }
  418. set{ vlinkcolor=value; }
  419. }
  420. private string textcolor;
  421. public string TextColor
  422. {
  423. get{ return textcolor; }
  424. set{ textcolor=value; }
  425. }
  426. private bool showfooter;
  427. public bool ShowFooter
  428. {
  429. get{ return showfooter; }
  430. set{ showfooter=value; }
  431. }
  432. private bool showheader;
  433. public bool ShowHeader
  434. {
  435. get{ return showheader; }
  436. set{ showheader=value; }
  437. }
  438. private string borderwidth = "0";
  439. public string BorderWidth
  440. {
  441. get{ return borderwidth; }
  442. set{ borderwidth = value; }
  443. }
  444. private string cssclass;
  445. public string CssClass
  446. {
  447. get{ return cssclass; }
  448. set{ cssclass=value; }
  449. }
  450. private string onclientactivate;
  451. public string OnClientActivate
  452. {
  453. get{ return onclientactivate; }
  454. set{ onclientactivate = value; }
  455. }
  456. private string onclientafterprint;
  457. public string OnClientAfterPrint
  458. {
  459. get{ return onclientafterprint; }
  460. set{ onclientafterprint = value; }
  461. }
  462. private string onclientbeforeactivate ;
  463. public string OnClientBeforeActivate
  464. {
  465. get{ return onclientbeforeactivate; }
  466. set{ onclientbeforeactivate = value; }
  467. }
  468. private string onclientbeforecut;
  469. public string OnClientBeforeCut
  470. {
  471. get{ return onclientbeforecut; }
  472. set{ onclientbeforecut = value; }
  473. }
  474. private string onclientbeforedeactivate;
  475. public string OnClientBeforeDeactivate
  476. {
  477. get{ return onclientbeforedeactivate; }
  478. set{ onclientbeforedeactivate = value; }
  479. }
  480. private string onclientbeforeeditfocus;
  481. public string OnClientBeforeEditFocus
  482. {
  483. get{ return onclientbeforeeditfocus; }
  484. set{ onclientbeforeeditfocus = value; }
  485. }
  486. private string onclientbeforepaste;
  487. public string OnClientBeforePaste
  488. {
  489. get{ return onclientbeforepaste; }
  490. set{ onclientbeforepaste = value; }
  491. }
  492. private string onclientbeforeprint;
  493. public string OnClientBeforePrint
  494. {
  495. get{ return onclientbeforeprint; }
  496. set{ onclientbeforeprint = value; }
  497. }
  498. private string onclientbeforeunload;
  499. public string OnClientBeforeUnload
  500. {
  501. get{ return onclientbeforeunload; }
  502. set{ onclientbeforeunload = value; }
  503. }
  504. private string onclientcontrolselect;
  505. public string OnClientControlSelect
  506. {
  507. get{ return onclientcontrolselect; }
  508. set{ onclientcontrolselect = value; }
  509. }
  510. private string onclientcut;
  511. public string OnClientCut
  512. {
  513. get{ return onclientcut; }
  514. set{ onclientcut = value; }
  515. }
  516. private string onclientdblclick;
  517. public string OnClientDblClick
  518. {
  519. get{ return onclientdblclick; }
  520. set{ onclientdblclick = value; }
  521. }
  522. private string onclientdeactivate;
  523. public string OnClientDeactivate
  524. {
  525. get{ return onclientdeactivate; }
  526. set{ onclientdeactivate = value; }
  527. }
  528. private string onclientdrag;
  529. public string OnClientDrag
  530. {
  531. get{ return onclientdrag; }
  532. set{ onclientdrag = value; }
  533. }
  534. private string onclientdragend;
  535. public string OnClientDragEnd
  536. {
  537. get{ return onclientdragend; }
  538. set{ onclientdragend = value; }
  539. }
  540. private string onclientdragenter;
  541. public string OnClientDragEnter
  542. {
  543. get{ return onclientdragenter; }
  544. set{ onclientdragenter = value; }
  545. }
  546. private string onclientdragleave;
  547. public string OnClientDragLeave
  548. {
  549. get{ return onclientdragleave; }
  550. set{ onclientdragleave = value; }
  551. }
  552. private string onclientdragover;
  553. public string OnClientDragOver
  554. {
  555. get{ return onclientdragover; }
  556. set{ onclientdragover = value; }
  557. }
  558. private string onclientdragstart;
  559. public string OnClientDragStart
  560. {
  561. get{ return onclientdragstart; }
  562. set{ onclientdragstart = value; }
  563. }
  564. private string onclientdrop;
  565. public string OnClientDrop
  566. {
  567. get{ return onclientdrop; }
  568. set{ onclientdrop = value; }
  569. }
  570. private string onclientfilterchange;
  571. public string OnClientFilterChange
  572. {
  573. get{ return onclientfilterchange; }
  574. set{ onclientfilterchange = value; }
  575. }
  576. private string onclientfocusin;
  577. public string OnClientFocusIn
  578. {
  579. get{ return onclientfocusin; }
  580. set{ onclientfocusin = value; }
  581. }
  582. private string onclientfocusout;
  583. public string OnClientFocusOut
  584. {
  585. get{ return onclientfocusout; }
  586. set{ onclientfocusout = value; }
  587. }
  588. private string onclientkeydown;
  589. public string OnClientKeyDown
  590. {
  591. get{ return onclientkeydown; }
  592. set{ onclientkeydown = value; }
  593. }
  594. private string onclientkeypress;
  595. public string OnClientKeyPress
  596. {
  597. get{ return onclientkeypress; }
  598. set{ onclientkeypress = value; }
  599. }
  600. private string onclientkeyup;
  601. public string OnClientKeyUp
  602. {
  603. get{ return onclientkeyup; }
  604. set{ onclientkeyup = value; }
  605. }
  606. private string onclientlosecapture;
  607. public string OnClientLoseCapture
  608. {
  609. get{ return onclientlosecapture; }
  610. set{ onclientlosecapture = value; }
  611. }
  612. private string onclientmousedown;
  613. public string OnClientMouseDown
  614. {
  615. get{ return onclientmousedown; }
  616. set{ onclientmousedown = value; }
  617. }
  618. private string onclientmouseenter;
  619. public string OnClientMouseEnter
  620. {
  621. get{ return onclientmouseenter; }
  622. set{ onclientmouseenter = value; }
  623. }
  624. private string onclientmouseleave;
  625. public string OnClientMouseLeave
  626. {
  627. get{ return onclientmouseleave; }
  628. set{ onclientmouseleave = value; }
  629. }
  630. private string onclientmousemove;
  631. public string OnClientMouseMove
  632. {
  633. get{ return onclientmousemove; }
  634. set{ onclientmousemove = value; }
  635. }
  636. private string onclientmouseout;
  637. public string OnClientMouseOut
  638. {
  639. get{ return onclientmouseout; }
  640. set{ onclientmouseout = value; }
  641. }
  642. private string onclientmouseover;
  643. public string OnClientMouseOver
  644. {
  645. get{ return onclientmouseover; }
  646. set{ onclientmouseover = value; }
  647. }
  648. private string onclientmouseup;
  649. public string OnClientMouseUp
  650. {
  651. get{ return onclientmouseup; }
  652. set{ onclientmouseup = value; }
  653. }
  654. private string onclientmousewheel;
  655. public string OnClientMouseWheel
  656. {
  657. get{ return onclientmousewheel; }
  658. set{ onclientmousewheel = value; }
  659. }
  660. private string onclientmove;
  661. public string OnClientMove
  662. {
  663. get{ return onclientmove; }
  664. set{ onclientmove = value; }
  665. }
  666. private string onclientmoveend;
  667. public string OnClientMoveEnd
  668. {
  669. get{ return onclientmoveend; }
  670. set{ onclientmoveend = value; }
  671. }
  672. private string onclientmovestart;
  673. public string OnClientMoveStart
  674. {
  675. get{ return onclientmovestart; }
  676. set{ onclientmovestart = value; }
  677. }
  678. private string onclientpaste;
  679. public string OnClientPaste
  680. {
  681. get{ return onclientpaste; }
  682. set{ onclientpaste = value; }
  683. }
  684. private string onclientpropertychange;
  685. public string OnClientPropertyChange
  686. {
  687. get{ return onclientpropertychange; }
  688. set{ onclientpropertychange = value; }
  689. }
  690. private string onclientreadystatechange;
  691. public string OnClientReadyStateChange
  692. {
  693. get{ return onclientreadystatechange; }
  694. set{ onclientreadystatechange = value; }
  695. }
  696. private string onclientresizeend;
  697. public string OnClientResizeEnd
  698. {
  699. get{ return onclientresizeend; }
  700. set{ onclientresizeend = value; }
  701. }
  702. private string onclientresizestart;
  703. public string OnClientResizeStart
  704. {
  705. get{ return onclientresizestart; }
  706. set{ onclientresizestart = value; }
  707. }
  708. private string onclientscroll;
  709. public string OnClientScroll
  710. {
  711. get{ return onclientscroll; }
  712. set{ onclientscroll = value; }
  713. }
  714. private string onclientselect;
  715. public string OnClientSelect
  716. {
  717. get{ return onclientselect; }
  718. set{ onclientselect = value; }
  719. }
  720. private string onclientselectstart;
  721. public string OnClientSelectStart
  722. {
  723. get{ return onclientselectstart; }
  724. set{ onclientselectstart = value; }
  725. }
  726. private string onclientunload;
  727. public string OnClientUnload
  728. {
  729. get{ return onclientunload; }
  730. set{ onclientunload = value; }
  731. }
  732. protected override void Render( HtmlTextWriter output )
  733. {
  734. if( null!=ALinkColor )
  735. output.AddAttribute( "alink",ALinkColor );
  736. if( null!=LinkColor )
  737. output.AddAttribute( "link",LinkColor );
  738. if( null!=VLinkColor )
  739. output.AddAttribute( "vlink",VLinkColor );
  740. if( null!=TextColor )
  741. output.AddAttribute( "text",TextColor );
  742. if( null!=BackgroundColor )
  743. output.AddAttribute( "bgcolor",BackgroundColor );
  744. if( null!=TopMargin )
  745. output.AddAttribute( "topmargin",TopMargin );
  746. if( null!=BottomMargin )
  747. output.AddAttribute( "bottommargin",BottomMargin );
  748. if( null!=LeftMargin )
  749. output.AddAttribute( "leftmargin",LeftMargin );
  750. if( null!=RightMargin )
  751. output.AddAttribute( "rightmargin",RightMargin );
  752. if( null!=MarginHeight )
  753. output.AddAttribute( "marginheight",MarginHeight );
  754. if( null!=MarginWidth )
  755. output.AddAttribute( "marginwidth",MarginWidth );
  756. if( null!=OnClientContextMenu )
  757. output.AddAttribute( "oncontextmenu",OnClientContextMenu );
  758. if( null!=OnClientLoad )
  759. output.AddAttribute( "onload",OnClientLoad );
  760. if( null!=OnClientActivate )
  761. output.AddAttribute( "onactive", OnClientActivate );
  762. if( null!=OnClientAfterPrint )
  763. output.AddAttribute( "onafterprint" ,OnClientAfterPrint );
  764. if( null!=OnClientBeforeActivate )
  765. output.AddAttribute( "onbeforeupdate",OnClientBeforeActivate );
  766. if( null!=OnClientBeforeCut )
  767. output.AddAttribute( "onbeforecut",OnClientBeforeCut );
  768. if( null!=OnClientBeforeDeactivate )
  769. output.AddAttribute( "onbeforedeactivate", OnClientBeforeDeactivate );
  770. if( null!=OnClientBeforeEditFocus )
  771. output.AddAttribute( "onbeforeeditfocus",OnClientBeforeEditFocus );
  772. if( null!=OnClientBeforePaste )
  773. output.AddAttribute( "onbeforepaste", OnClientBeforePaste );
  774. if( null!=OnClientBeforePrint )
  775. output.AddAttribute( "onbeforeprint", OnClientBeforePrint );
  776. if( null!=OnClientBeforeUnload )
  777. output.AddAttribute( "onbeforeunload", OnClientBeforeUnload );
  778. if( null!=OnClientControlSelect )
  779. output.AddAttribute( "oncontrolselect", OnClientControlSelect );
  780. if( null!=OnClientCut )
  781. output.AddAttribute( "oncut", OnClientCut );
  782. if( null!=OnClientDblClick )
  783. output.AddAttribute( "ondblclick", OnClientDblClick );
  784. if( null!=OnClientDeactivate )
  785. output.AddAttribute( "ondeactivate", OnClientDeactivate );
  786. if( null!=OnClientDrag )
  787. output.AddAttribute( "ondrag", OnClientDrag );
  788. if( null!=OnClientDragEnd )
  789. output.AddAttribute( "ondragend", OnClientDragEnd );
  790. if( null!=OnClientDragEnter )
  791. output.AddAttribute( "ondragenter", OnClientDragEnter );
  792. if( null!=OnClientDragLeave )
  793. output.AddAttribute( "ondragleave", OnClientDragLeave );
  794. if( null!=OnClientDragOver )
  795. output.AddAttribute( "ondragover", OnClientDragOver );
  796. if( null!=OnClientDragStart )
  797. output.AddAttribute( "ondragstart", OnClientDragStart );
  798. if( null!=OnClientDrop )
  799. output.AddAttribute( "ondrop", OnClientDrop );
  800. if( null!=OnClientFilterChange )
  801. output.AddAttribute( "onfilterchange", OnClientFilterChange );
  802. if( null!=OnClientFocusIn )
  803. output.AddAttribute( "onfocusin", OnClientFocusIn );
  804. if( null!=OnClientFocusOut )
  805. output.AddAttribute( "onfocusout", OnClientFocusOut );
  806. if( null!=OnClientKeyDown )
  807. output.AddAttribute( "onkeydown", OnClientKeyDown );
  808. if( null!=OnClientKeyPress )
  809. output.AddAttribute( "onkeypress", OnClientKeyPress );
  810. if( null!=OnClientKeyUp )
  811. output.AddAttribute( "onkeyup", OnClientKeyUp );
  812. if( null!=OnClientLoseCapture )
  813. output.AddAttribute( "onlosecapture", OnClientMouseDown );
  814. if( null!=OnClientMouseDown )
  815. output.AddAttribute( "onmousedown", OnClientMouseDown );
  816. if( null!=OnClientMouseEnter )
  817. output.AddAttribute( "onmouseenter", OnClientMouseEnter );
  818. if( null!=OnClientMouseLeave )
  819. output.AddAttribute( "onmouseleave", OnClientMouseLeave );
  820. if( null!=OnClientMouseMove )
  821. output.AddAttribute( "onmousemove", OnClientMouseMove );
  822. if( null!=OnClientMouseOut )
  823. output.AddAttribute( "onmouseout", OnClientMouseOut );
  824. if( null!=OnClientMouseOver )
  825. output.AddAttribute( "onmouseover", OnClientMouseOver );
  826. if( null!=OnClientMouseUp )
  827. output.AddAttribute( "onmouseup", OnClientMouseUp );
  828. if( null!=OnClientMouseWheel )
  829. output.AddAttribute( "onmousewheel", OnClientMouseWheel );
  830. if( null!=OnClientMove )
  831. output.AddAttribute( "onmove", OnClientMove );
  832. if( null!=OnClientMoveEnd )
  833. output.AddAttribute( "onmoveend", OnClientMoveEnd );
  834. if( null!=OnClientMoveStart )
  835. output.AddAttribute( "onmovestart", OnClientMoveStart );
  836. if( null!=OnClientPaste )
  837. output.AddAttribute( "onpaste", OnClientPaste );
  838. if( null!=OnClientPropertyChange )
  839. output.AddAttribute( "onpropertychange", OnClientPropertyChange );
  840. if( null!=OnClientReadyStateChange )
  841. output.AddAttribute( "onreadystatechange", OnClientReadyStateChange );
  842. if( null!=OnClientResizeEnd )
  843. output.AddAttribute( "onresizeend", OnClientResizeEnd );
  844. if( null!=OnClientResizeStart )
  845. output.AddAttribute( "onresizestart", OnClientResizeStart );
  846. if( null!=OnClientScroll )
  847. output.AddAttribute( "onscroll", OnClientScroll );
  848. if( null!=OnClientSelect )
  849. output.AddAttribute( "onselect", OnClientSelect );
  850. if( null!=OnClientSelectStart )
  851. output.AddAttribute( "onselectstart", OnClientSelectStart );
  852. if( null!=OnClientUnload )
  853. output.AddAttribute( "onunload", OnClientUnload );
  854. }
  855. public static PageStyleControl GetDefault()
  856. {
  857. PageStyleControl control = new PageStyleControl();
  858. //TODO: Build other defaults in.
  859. return control;
  860. }
  861. }
  862. public class UddiControl : System.Web.UI.UserControl
  863. {
  864. public bool IsDownlevel
  865. {
  866. get { return UddiBrowser.IsDownlevel; }
  867. }
  868. public virtual bool EditMode
  869. {
  870. get { return ((UddiPage)Page).EditMode; }
  871. }
  872. public string Root
  873. {
  874. get { return ((UddiPage)Page).Root; }
  875. }
  876. public virtual void CancelEditMode()
  877. {
  878. ((UddiPage)Page).CancelEditMode();
  879. }
  880. public virtual void SetEditMode()
  881. {
  882. ((UddiPage)Page).SetEditMode();
  883. }
  884. }
  885. public class UddiButton : System.Web.UI.WebControls.Button
  886. {
  887. protected bool editModeDisable = false;
  888. protected bool focus = false;
  889. public bool EditModeDisable
  890. {
  891. get { return editModeDisable; }
  892. set { editModeDisable = value; }
  893. }
  894. public bool Focus
  895. {
  896. get { return focus; }
  897. set { focus = value; }
  898. }
  899. public new string Text
  900. {
  901. get { return base.Text; }
  902. set
  903. {
  904. //
  905. // Check to see if the button text needs to be localized. We
  906. // use strings of the form [[ID]] to indicate localization is
  907. // needed.
  908. //
  909. if( null != value && value.StartsWith( "[[" ) && value.EndsWith( "]]" ) )
  910. base.Text = Localization.GetString( value.Substring( 2, value.Length - 4 ) );
  911. else
  912. base.Text = value;
  913. }
  914. }
  915. protected override void Render( HtmlTextWriter output )
  916. {
  917. bool enabled = Enabled;
  918. //
  919. // Check to see if we need to disable this control. We do
  920. // this if we are in edit mode and the control is set to
  921. // autodisable.
  922. //
  923. if( EditModeDisable && ((UddiPage)Page).EditMode )
  924. Enabled = false;
  925. //
  926. // Only render the control if it is enabled, or we're on an IE
  927. // browser. Netscape and other browsers do not support the
  928. // enabled attribute, so we have to prevent the control from
  929. // rendering on these browsers.
  930. //
  931. if( Enabled || UddiBrowser.IsIE5 )
  932. {
  933. if( Focus )
  934. {
  935. Page.RegisterStartupScript(
  936. "SetFocus",
  937. "<script language='javascript'>SetFocus( '" + UniqueID + "' )</script>" );
  938. }
  939. base.Render( output );
  940. }
  941. Enabled = enabled;
  942. }
  943. }
  944. public class UddiCheckBox : System.Web.UI.WebControls.CheckBox
  945. {
  946. protected bool editModeDisable = false;
  947. protected bool focus = false;
  948. public bool EditModeDisable
  949. {
  950. get { return editModeDisable; }
  951. set { editModeDisable = value; }
  952. }
  953. public bool Focus
  954. {
  955. get { return focus; }
  956. set { focus = value; }
  957. }
  958. public override string Text
  959. {
  960. get { return base.Text; }
  961. set
  962. {
  963. //
  964. // Check to see if the button text needs to be localized. We
  965. // use strings of the form [[ID]] to indicate localization is
  966. // needed.
  967. //
  968. if( null != value && value.StartsWith( "[[" ) && value.EndsWith( "]]" ) )
  969. base.Text = Localization.GetString( value.Substring( 2, value.Length - 4 ) );
  970. else
  971. base.Text = value;
  972. }
  973. }
  974. protected override void Render( HtmlTextWriter output )
  975. {
  976. bool enabled = Enabled;
  977. //
  978. // Check to see if we need to disable this control. We do
  979. // this if we are in edit mode and the control is set to
  980. // autodisable.
  981. //
  982. if( EditModeDisable && ((UddiPage)Page).EditMode )
  983. Enabled = false;
  984. //
  985. // Only render the control if it is enabled, or we're on an IE
  986. // browser. Netscape and other browsers do not support the
  987. // enabled attribute, so we have to prevent the control from
  988. // rendering on these browsers.
  989. //
  990. if( Enabled || UddiBrowser.IsIE5 )
  991. {
  992. if( Focus )
  993. {
  994. Page.RegisterStartupScript(
  995. "SetFocus",
  996. "<script language='javascript'>SetFocus( '" + UniqueID + "' )</script>" );
  997. }
  998. base.Render( output );
  999. }
  1000. Enabled = enabled;
  1001. }
  1002. }
  1003. public class UddiLabel : System.Web.UI.WebControls.Label
  1004. {
  1005. protected override void Render( HtmlTextWriter output )
  1006. {
  1007. //
  1008. // Check to see if the label text needs to be localized. We
  1009. // use strings of the form [[ID]] to indicate localization is
  1010. // needed.
  1011. //
  1012. string text = base.Text;
  1013. if( null != text && text.StartsWith( "[[" ) && text.EndsWith( "]]" ) )
  1014. {
  1015. text = Localization.GetString( text.Substring( 2, text.Length - 4 ) );
  1016. }
  1017. else
  1018. {
  1019. text = HttpUtility.HtmlEncode( text );
  1020. if( null != text )
  1021. text = text.Replace( "\n", "<br>" ).Replace( " ", "&nbsp; " );
  1022. }
  1023. base.AddAttributesToRender( output );
  1024. output.RenderBeginTag( HtmlTextWriterTag.Span );
  1025. output.Write( text );
  1026. output.RenderEndTag();
  1027. }
  1028. }
  1029. public class UddiTextBox : System.Web.UI.WebControls.TextBox, IPostBackEventHandler
  1030. {
  1031. protected bool editModeDisable = false;
  1032. protected bool selected = false;
  1033. protected bool focus = false;
  1034. public bool Selected
  1035. {
  1036. get { return selected; }
  1037. set { selected = value; }
  1038. }
  1039. public override string Text
  1040. {
  1041. get
  1042. {
  1043. //
  1044. // BUG: 759949. We must strip invalid characters from the strings.
  1045. //
  1046. if( null != base.Text )
  1047. return Utility.XmlEncode( base.Text );
  1048. else
  1049. return base.Text;
  1050. }
  1051. set
  1052. {
  1053. base.Text = value;
  1054. }
  1055. }
  1056. public bool Focus
  1057. {
  1058. get { return focus; }
  1059. set { focus = value; }
  1060. }
  1061. public bool EditModeDisable
  1062. {
  1063. get { return editModeDisable; }
  1064. set { editModeDisable = value; }
  1065. }
  1066. public event EventHandler EnterKeyPressed;
  1067. void IPostBackEventHandler.RaisePostBackEvent( string eventArgument )
  1068. {
  1069. switch( eventArgument )
  1070. {
  1071. case "enterkey":
  1072. if( null != EnterKeyPressed )
  1073. EnterKeyPressed( this, new EventArgs() );
  1074. break;
  1075. }
  1076. }
  1077. protected override void Render( HtmlTextWriter output )
  1078. {
  1079. if( EditModeDisable && ((UddiPage)Page).EditMode )
  1080. {
  1081. output.AddAttribute(HtmlTextWriterAttribute.Disabled, null );
  1082. }
  1083. else
  1084. {
  1085. if( Selected )
  1086. {
  1087. Page.RegisterStartupScript(
  1088. "Select",
  1089. "<script language='javascript'>Select( '" + UniqueID + "' )</script>" );
  1090. }
  1091. else if( Focus )
  1092. {
  1093. Page.RegisterStartupScript(
  1094. "SetFocus",
  1095. "<script language='javascript'>SetFocus( '" + UniqueID + "' )</script>" );
  1096. }
  1097. if( null != EnterKeyPressed )
  1098. output.AddAttribute( "onkeypress", "if( 13 == event.keyCode ) " + Page.GetPostBackEventReference( this, "enterkey" ) );
  1099. }
  1100. base.Render( output );
  1101. }
  1102. }
  1103. public class UddiDataGrid : System.Web.UI.WebControls.DataGrid, IPostBackEventHandler
  1104. {
  1105. void IPostBackEventHandler.RaisePostBackEvent( string eventArgument )
  1106. {
  1107. int page = Convert.ToInt32( eventArgument );
  1108. OnPageIndexChanged(
  1109. new System.Web.UI.WebControls.DataGridPageChangedEventArgs( this, page ) );
  1110. }
  1111. protected override void Render( HtmlTextWriter output )
  1112. {
  1113. bool paging = AllowPaging;
  1114. AllowPaging = false;
  1115. base.Render( output );
  1116. if( paging )
  1117. {
  1118. // TODO: Localize!!!
  1119. output.AddAttribute( HtmlTextWriterAttribute.Class, "pagingFooter" );
  1120. output.RenderBeginTag( HtmlTextWriterTag.Span );
  1121. output.Write( String.Format( "Page {0} of {1}: ", CurrentPageIndex + 1, PageCount ) );
  1122. int startPage = ( CurrentPageIndex / PagerStyle.PageButtonCount ) * PagerStyle.PageButtonCount;
  1123. int stopPage = Math.Min( startPage + PagerStyle.PageButtonCount - 1, PageCount - 1 );
  1124. for( int page = startPage; page <= stopPage; page ++ )
  1125. {
  1126. if( page == CurrentPageIndex )
  1127. {
  1128. output.AddAttribute( HtmlTextWriterAttribute.Class, "pageSelected" );
  1129. output.RenderBeginTag( HtmlTextWriterTag.Span );
  1130. output.Write( "&nbsp;" + ( page + 1 ) + "&nbsp;" );
  1131. output.RenderEndTag();
  1132. }
  1133. else
  1134. {
  1135. output.AddAttribute( HtmlTextWriterAttribute.Class, "page" );
  1136. output.AddAttribute( HtmlTextWriterAttribute.Href, "javascript:" + Page.GetPostBackEventReference( this, page.ToString() ) );
  1137. output.RenderBeginTag( HtmlTextWriterTag.A );
  1138. output.Write( "&nbsp;" + ( page + 1 ) + "&nbsp;" );
  1139. output.RenderEndTag();
  1140. }
  1141. }
  1142. output.RenderEndTag();
  1143. }
  1144. }
  1145. }
  1146. public class HyperLinkManager
  1147. {
  1148. public static string GetSecureHyperLink( string pagename )
  1149. {
  1150. string url = "";
  1151. bool isAbsolute = false;
  1152. int port = Config.GetInt( "Web.HttpsPort",UDDI.Constants.Web.HttpsPort );
  1153. //
  1154. // if
  1155. // the current context is not secure, and we require HTTPS,
  1156. // - OR -
  1157. // The Web.HttpsPort is something other than the Default and the current port is not what is configured
  1158. //
  1159. // we will need to generate an absolute path.
  1160. //
  1161. isAbsolute = ( ( !HttpContext.Current.Request.IsSecureConnection &&
  1162. 1==Config.GetInt( "Security.HTTPS", UDDI.Constants.Security.HTTPS ) ) ||
  1163. ( UDDI.Constants.Web.HttpsPort!=port && HttpContext.Current.Request.Url.Port!=port ) );
  1164. if( isAbsolute )
  1165. {
  1166. url = GetUrlStart( true );
  1167. }
  1168. url+=GetFullFilePath( pagename );
  1169. return url;
  1170. }
  1171. public static string GetHyperLink( string pagename )
  1172. {
  1173. return GetHyperLink( pagename, false );
  1174. }
  1175. public static string GetHyperLink( string pagename, bool absolute )
  1176. {
  1177. string url = "";
  1178. if( absolute )
  1179. {
  1180. url = GetUrlStart( HttpContext.Current.Request.IsSecureConnection );
  1181. }
  1182. url += GetFullFilePath( pagename );
  1183. return url;
  1184. }
  1185. public static string GetNonSecureHyperLink( string pagename )
  1186. {
  1187. string url = "";
  1188. int port = Config.GetInt( "Web.HttpPort",UDDI.Constants.Web.HttpPort );
  1189. bool isAbsolute = false;
  1190. //
  1191. // if the current context is secure,
  1192. // - or -
  1193. // the Web.HttpPort is something other than default, and current port is not what is configured
  1194. // we will need to generate an absolute path.
  1195. //
  1196. isAbsolute = HttpContext.Current.Request.IsSecureConnection ||
  1197. ( UDDI.Constants.Web.HttpPort!=port && HttpContext.Current.Request.Url.Port!=port );
  1198. if( isAbsolute )
  1199. {
  1200. url = GetUrlStart( false );
  1201. }
  1202. url += GetFullFilePath( pagename );
  1203. return url;
  1204. }
  1205. private static string GetUrlStart( bool secure )
  1206. {
  1207. string url = "";
  1208. int port = 0;
  1209. if( secure )//build a secure url
  1210. {
  1211. url = "https://" + HttpContext.Current.Request.Url.Host;
  1212. port = Config.GetInt( "Web.HttpsPort",UDDI.Constants.Web.HttpsPort );
  1213. if( port!=UDDI.Constants.Web.HttpsPort )
  1214. url += ":" + port.ToString();
  1215. }
  1216. else//build no secure url
  1217. {
  1218. url = "http://" + HttpContext.Current.Request.Url.Host;
  1219. port = Config.GetInt( "Web.HttpPort",UDDI.Constants.Web.HttpPort );
  1220. if( port!=UDDI.Constants.Web.HttpPort )
  1221. url += ":" + port.ToString();
  1222. }
  1223. return url;
  1224. }
  1225. private static string GetFullFilePath( string file )
  1226. {
  1227. string url = ( ( "/"==HttpContext.Current.Request.ApplicationPath) ? "" : HttpContext.Current.Request.ApplicationPath );
  1228. url += file ;
  1229. return url;
  1230. }
  1231. }
  1232. public enum UrlFlags
  1233. {
  1234. Https = 0x0001,
  1235. Require = 0x0002,
  1236. Absolute = 0x0004,
  1237. External = 0x0008
  1238. }
  1239. public enum UrlOptions
  1240. {
  1241. PreferHttp = 0x0000,
  1242. PreferHttps = 0x0001,
  1243. RequireHttp = 0x0002,
  1244. RequireHttps = 0x0003,
  1245. PreferHttpAbsolute = 0x0004,
  1246. PreferHttpsAbsolute = 0x0005,
  1247. RequireHttpAbsolute = 0x0006,
  1248. RequireHttpsAbsolute = 0x0007,
  1249. External = 0x0008
  1250. }
  1251. }