// Register the script file with the client
Public static bool registscript (page, string path)
{
Bool isregisted = false;
If (! String. isnullorempty (PATH ))
{
Path = page. resolveurl (PATH );
If (! Page. clientscript. isclientscriptincluderegistered (page. GetType (), PATH) // you can check whether the client has registered the script file.
{
Page. clientscript. registerclientscriptinclude (page. GetType (), path, PATH); // register the specified script file with the client
Isregisted = true;
}
}
Return isregisted;
}
// Dynamically register CSS files with the client to avoid CSS conflicts on the IE registration page due to repeated CSS file registration
Public Static Bool Registcss (Page, string pathcss) {bool Addcss = True ; If (Page. header! = Null ) {Controlcollection Cccollection = Page. header. controls; If (Cccollection. Count> 0 ){ Foreach (Control Citem In Cccollection ){ If (Citem. GetType () = Typeof (Htmllink) {htmllink Hllink = Citem As Htmllink; If (Hllink. attributes [ "Href" ]. Tostring () = page. resolveurl (pathcss) {addcss = False ;}}}} If (Addcss) {htmllink Csslink =New Htmllink {href = page. resolveurl (pathcss)}; csslink. Attributes. Add ( "Rel" , "Stylesheet" ); Csslink. Attributes. Add ( "Type" , "Text/CSS" ); Page. Page. header. Controls. Add (csslink );}} Return Addcss ;} |