2

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 ?

2
  • Do any of these do what you want? pixelzdesign.com/blog_view.php?id=59 GIYF Commented Apr 3, 2012 at 9:26
  • Can I do it inside the control.I cannot use a separate JavaScript file. I have to do it everything inside the control itself. I am using asp.net 2.0 without ajax Commented Apr 3, 2012 at 9:37

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

3 Comments

I've already tried this. But it is not working in my case :-( . Actually my control has a label,text box and Image Control.What I need is to draw a re-sizable rectangle on the image
You could try using jquery to help with the resizable rectangle. check out resizable
How do I access controls from the script.When I tried accessing using getElementById("controlname") it returns null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.