Programmatically adding Javascript File to User Control in .net

后端 未结 8 1969
不知归路
不知归路 2020-12-24 08:08

How do you add Javascript file programmatically to the user control?

I want the user control to be a complete package - ie I don\'t want to have to add javascript th

8条回答
  •  误落风尘
    2020-12-24 09:00

    Good question!

    A UserControl should be a single package without any dependency on a JavaScript or a CSS file. You will need to make the JS and CSS files as embedded resources. Right click properties and set build action to embedded resources. Then you need to inject the JavaScript and CSS files as WebResources.

    Here is one article that I wrote yesterday which talks about the same scenario:

    http://highoncoding.com/Articles/502_Creating_RadioButton_Validation_Using_Custom_Validator.aspx

提交回复
热议问题