I have a custom asp.net server control to display images.What I need now is to draw a rectangle on the center of image and the rectangle should be re sizable by dragging on its edges.Is it possible to accomplish this using JavaScript ?. I need to embed that script in that control. Is it possible ?

有帮助吗?

解决方案

You can include a javascript file in a server control.

Add a reference to the assemblyinfo.cs

[assembly: WebResource("Custom.js", "text/javascript")]

Then a reference on the PreRender:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    string resourceName = "Custom.js";

    ClientScriptManager cs = this.Page.ClientScript;
    cs.RegisterClientScriptResource(typeof(CustomControls.Custom), resourceName);
}

Here is a nice article on the subject

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top