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 ?
Asked
Active
Viewed 1,394 times
2
-
Do any of these do what you want? http://www.pixelzdesign.com/blog_view.php?id=59 GIYF – dash Apr 03 '12 at 09: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 – Senan Apr 03 '12 at 09:37
1 Answers
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);
}

Dave D
- 691
- 5
- 11
-
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 – Senan Apr 03 '12 at 12:10
-
You could try using jquery to help with the resizable rectangle. check out [resizable](http://jqueryui.com/demos/resizable/#default) – Dave D Apr 03 '12 at 13:58
-
1How do I access controls from the script.When I tried accessing using getElementById("controlname") it returns null – Senan Apr 13 '12 at 04:41