locked
embedding javascript and images in custom server control RRS feed

  • Question

  • User151722123 posted

    HI EVERYBODY,

    plz take a look at my problem.

    I am making a editor server control. I want to embed javascript and images in server control.

    I have done the following things.

    1. set file as embedded resource.

    2 in assembly.info file i have written the following

    [assembly: WebResource("mail2mohanpyare.mirageeditor.js", "text/js")]
    [assembly: WebResource("mail2mohanpyare.contents.css","text/css")]


    on control prerender event

    string js1 = Page.ClientScript.GetWebResourceUrl(this.GetType(), "ClassLibrary1.mail2mohanpyare.mirageeditor.js");
                Page.ClientScript.RegisterClientScriptInclude("ClassLibrary1.mail2mohanpyare.mirageeditor.js", js1);


    var cssLink = new HtmlGenericControl("link") { ID = "cssLinkID" };
                cssLink.Attributes.Add("href", Page.ClientScript.GetWebResourceUrl(typeof(mail2mohanpyare), "ClassLibrary1.mail2mohanpyare.contents.css"));
                cssLink.Attributes.Add("rel", "stylesheet");
                cssLink.Attributes.Add("type", "text/css");
                Page.Header.Controls.Add(cssLink);


    page source

    <script src="/WebResource.axd?d=DvhhSQv0xmPx8IdocS8sLjBClJqOnJ-5nQOGdLve3DvFx7VXKQ2KUqyylg3Nmf78wmXUUY40YJHsx2zlT2sAJA2&amp;t=634003791690781250" type="text/javascript"></script>
    <script src="/WebResource.axd?d=DvhhSQv0xmPx8IdocS8sLjBClJqOnJ-5nQOGdLve3DvFx7VXKQ2KUqyylg3Nmf78wmXUUY40YJHsx2zlT2sAJA2&amp;t=634003791690781250" type="text/javascript"></script>

    BUT MY PAGE IS NOT SHOWING STYLES WHEN I USE THIS CONTROL. ONE MORE THING HOW TO DISPLAY EMBEDDED IMAGES.

    Friday, January 29, 2010 6:14 AM

Answers

  • User-1659704165 posted

    Hi,

    http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXExtensibilityTutorials.aspx

    http://www.asp.net/AJAX/Documentation/Live/tutorials/IScriptControlTutorial1.aspx

    u may chk the above link

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 1, 2010 5:03 AM
  • User-16411453 posted

    I don't code in cs so I'm not much help. I tried to explain this before 3 weeks ago,you have to create a client script manager.

    ClientScriptManager cs = This.Page.ClientScript;

    Type rsType = This.GetType

    If(!cs.IsClientScriptIncludeRegistered(rsType, "MyJavascript")) {

    cs.RegisterClientScriptInclude("MyJavascript", cs.GetWebResourceUrl(rsType, "RootNameSpace".MyJavascriptFileName.js))

    }

    .ImageUrl = cs.GetWebResourceUrl(rsType, "RootNameSpace".MyImage.png)

    oh, don't call me dear

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 2, 2010 7:29 PM

All replies

  • User-1659704165 posted

    Hi,

    http://www.asp.net/AJAX/Documentation/Live/tutorials/ASPNETAJAXExtensibilityTutorials.aspx

    http://www.asp.net/AJAX/Documentation/Live/tutorials/IScriptControlTutorial1.aspx

    u may chk the above link

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 1, 2010 5:03 AM
  • User-16411453 posted

    I don't code in cs so I'm not much help. I tried to explain this before 3 weeks ago,you have to create a client script manager.

    ClientScriptManager cs = This.Page.ClientScript;

    Type rsType = This.GetType

    If(!cs.IsClientScriptIncludeRegistered(rsType, "MyJavascript")) {

    cs.RegisterClientScriptInclude("MyJavascript", cs.GetWebResourceUrl(rsType, "RootNameSpace".MyJavascriptFileName.js))

    }

    .ImageUrl = cs.GetWebResourceUrl(rsType, "RootNameSpace".MyImage.png)

    oh, don't call me dear

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 2, 2010 7:29 PM