This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Resizing BitmapViewer Web Control on Client Side

Hello everyone,

Here is simple code how to resize BitmapViewer web control on client side:

<%@ Page Language="vb" AutoEventWireup="false"%>
<%@ Register TagPrefix="aur" Namespace="Aurigma.GraphicsMill.WebControls" Assembly="Aurigma.GraphicsMill.WebControls" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	If Not Page.IsPostBack Then
		BitmapViewer1.Bitmap.Load(Server.MapPath("TestImages/building.jpg"))
	Else
		'Check whether control width and height were changed on client side
		If Request.Form("newWidth")<>"" And Request.Form("newHeight")<>"" Then
			BitmapViewer1.Width=Unit.op_Implicit(Int32.Parse(Request.Form("newWidth")))
			BitmapViewer1.Height=Unit.op_Implicit(Int32.Parse(Request.Form("newHeight")))
		End If
	End If
End Sub
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<LINK href="Style.css" type="text/css" rel="stylesheet">
		<script language="javascript">
function resizeBitmapViewer(){
	var bitmapViewer1=document.getElementById("<%=BitmapViewer1.ClientID%>");
	var newWidth=640;
	var newHeight=480;
	
	//Resize control
	bitmapViewer1.style.width=newWidth+"px";
	bitmapViewer1.style.height=newHeight+"px";
	
	//Refresh control
	bitmapViewer1.delayedRefresh();

	//Save width and height in hidden form fields for syncing on server-side
	document.getElementById("newWidth").value=newWidth;
	document.getElementById("newHeight").value=newHeight;	
}
			</script>
	</HEAD>
	<body>
		<form id="Form1" runat="server">
			<input type="button" value="Resize Bitmap Viewer" onclick="resizeBitmapViewer()">
			
			<input type="hidden" value="" name="newWidth" id="newWidth">
			<input type="hidden" value="" name="newHeight" id="newHeight">
	
			<asp:Button Runat="server" Text="Make Roundtrip"></asp:Button>	
		
			<aur:bitmapviewer id="BitmapViewer1" runat="server" Width="344" height="270"
				BorderWidth="2" BorderStyle="Inset" ScrollBarsStyle="Auto" BackColor="White" Zoom="4"></aur:bitmapviewer>
		</form>
	</body>
</HTML>