ImageGear for .NET User Guide > Getting Started > ImageGear for .NET Visual Studio 2012 Tutorials > ImageGear for .NET ASP.NET Tutorial > Adding Event Handlers |
Copy Code | |
---|---|
<head runat="server"> <title>ASP.NET Tutorial</title> <script type="text/javascript"> </script> </head> |
Copy Code | |
---|---|
<script type="text/javascript"> function Button1_onclick() { $find('PageView1').fitImage(ImageGear.Web.UI.FitType.FullImage); } </script> |
Copy Code | |
---|---|
<input id="Button1" type="button" value="Show Full Image" onclick="Button1_onclick()" /> |
Copy Code | |
---|---|
function Button2_onclick() {
$find('PageView1').rotate(90);
} |
Copy Code | |
---|---|
<input id="Button2" type="button" value="Rotate Right" onclick="Button2_onclick()" /> |
Copy Code | |
---|---|
function Button3_onclick() { var mark = new ImageGear.Web.UI.Mark(ImageGear.Web.UI.MarkType.Ellipse); mark.set_rectangle(new ImageGear.Web.UI.Rectangle(Math.random() * 800, Math.random() * 800, 800, 350)); mark.set_fillColor('#ffc0cb'); mark.set_lineWidth(10); mark.set_lineColor('#008020'); mark.set_opacity(127); $find('PageView1').get_artPage().addMark(mark); } |
Copy Code | |
---|---|
<input id="Button3" type="button" value="Draw Ellipse" onclick="Button3_onclick()" /> |
Copy Code | |
---|---|
function Button4_onclick() { var _ctrlView = $find('PageView1'); if (_ctrlView.get_pageIsOpen() == true) { _ctrlView.closePage(); } _ctrlView.openPage({ documentIdentifier: 'FileImageDataProvider1:myImage.tif', pageNumber: 2, viewFitType: ImageGear.Web.UI.FitType.ActualSize }); } |
Then, bind this method with Button4 event:
Copy Code | |
---|---|
<input id="Button4" type="button" value="Data Provider 1" onclick="Button4_onclick()" /> |
You will need to find the myImage.tif file from the .\ImageGear.NET v21\Samples\ASP.NET\CSharp\ ASP.NET Tutorial folder installed sample or use another image but change myImage.tif in the above code to the image name being used. The pageNumber value may need to be changed to 0 if the image is a single page document.
Copy Code | |
---|---|
function Button5_onclick() { var _ctrlView = $find('PageView1'); if (_ctrlView.get_pageIsOpen() == true) { _ctrlView.closePage(); } _ctrlView.openPage({ documentIdentifier: 'FileImageDataProvider2:ccitt.tif', pageNumber: 2, viewFitType: ImageGear.Web.UI.FitType.ActualSize }); } |
To the script section, and bind this method with Button5 click event:
Copy Code | |
---|---|
<input id="Button5" type="button" value="Data Provider 2" onclick="Button5_onclick()" /> |
Find the ccitt.tif as done in Step 9 above or use a different document image, but make the corresponding code changes for the name and pageNumber as in Step 9 appropriately.
Copy Code | |
---|---|
<ImageGear.Web.DataProviders.ImageProvider default="FileImageDataProvider1" parseToken=":"> <providers> <add name="FileImageDataProvider1" type="ImageGear.Web.DataProviders.FileImageDataProvider,ImageGear21.Web.Services" storageRootPath="~/viewerImages/" maxImageSizeToCache="512" cachingTimeLimit="5" cachingEnable="false" /> <add name="FileImageDataProvider2" type="ImageGear.Web.DataProviders.FileImageDataProvider,ImageGear21.Web.Services" storageRootPath="~/viewerImages2/" maxImageSizeToCache="512" cachingTimeLimit="5" cachingEnable="false" /> </providers> </ImageGear.Web.DataProviders.ImageProvider> |
The parseToken attribute defined in the ImageProvider section determines what character or set of characters that define the separation between the data provider name and the document identifier. In this example, the ":" is used for the separation character. If the parseToken attribute is not provided, the "!" character is the default separator. |