Skip to content

How to Zoomin from clientside

Milton Smith

Asked May 8, 2008, 10:25 PM EDT2 answers
Share
LinkedInX

I am designing a layout for a floor. I want to include zoom in and zoom out feature  from client side.I have a div and i made position = absolute,to give my lay out proper looks. I am calling a java script function for zoomin and zoomout. If I remove the position it is Zooming but with position= absolute it is not zooming.But  in my case position= absolute is important for looks. So anybody tell me how to ZOOM in from client side when position= absolute is activated.

 

 

My java script function is as follows:

 

Code
function zoomin(){
if(parent.parent.document.body.style.zoom!=0)
parent.parent.document.body.style.zoom*=1.2;
else
parent.parent.document.body.style.zoom=1.2;
}

 

My .cs code is as follows:

 

 

C#
string strSQL = "SELECT bdm_txt_BuildingType, bdm_txt_Caption, bdm_num_Left, bdm_num_Top,bdm_num_Length, bdm_num_Breadth, bdm_num_FontSize FROM BuildingDimensions WHERE bdm_num_PartId = " + Session["Id"] + " ";
DataSet dstData = new DataSet();
objDataAccess.GetDataSet(ref dstData, strSQL, "Event");
for (int intIndex = 0; intIndex "Event"].Rows.Count; intIndex++)
{
dblBuildLeft = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Left"]) * 38 * 0.0576;
dblBuildTop = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Top"]) * 38 * 0.0576;
dblBuildTop = dblBuildTop + 45;
dblBuildWidth = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Length"]) * 38 * 0.0576;
dblBuildHeight = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Breadth"]) * 38 * 0.0576;
strCaption = dstData.Tables["Event"].Rows[intIndex]["bdm_txt_Caption"].ToString();

hidSecLBreadth.Value = hidSecLBreadth.Value + "

";

C#
hidSecLBreadth.Value = hidSecLBreadth.Value + "<DIV id='div2'style = 'BORDER-RIGHT: 1px solid;BORDER-TOP: 1px solid;BORDER-LEFT: 1px solid;BORDER-BOTTOM: 1px solid;";
hidSecLBreadth.Value = hidSecLBreadth.Value + " position:absolute; width:" + dblBuildWidth + "px; height:";
dblTotalWidth =+ dblBuildWidth;
hidSecLBreadth.Value = hidSecLBreadth.Value + dblBuildHeight + "px; z-index:4; left: " + dblBuildLeft;
hidSecLBreadth.Value = hidSecLBreadth.Value + "px; top: " + dblBuildTop + "px; background-color:#C0C0C0;";
hidSecLBreadth.Value = hidSecLBreadth.Value + " layer-background-color: #C0C0C0'>" + strCaption + "</DIV>";
hidSecLBreadth.Value = hidSecLBreadth.Value + " ";
}

I am displaying the hidSecLBreadth.Value into a label in .aspx page.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Niradhip Chakraborty
    0

    I have modified your code by taking a hidden variablle and give a id to each time it is looping. I also have modify the java script function.Try it and if you have any doubt please tell me.The bold letters are added by me to work zoomin from client side.

     

    C#
    string strSQL = "SELECT distinct bdm_seq_BuildingId,bdm_txt_BuildingType, bdm_txt_Caption, bdm_num_Left, bdm_num_Top,bdm_num_Length, bdm_num_Breadth, bdm_num_FontSize FROM BuildingDimensions WHERE bdm_num_PartId = " + Session["Id"] + " ";
    DataSet dstData = new DataSet();
    objDataAccess.GetDataSet(ref dstData, strSQL, "Event");
    string strBuildingNo;
    
    for (int intIndex = 0; intIndex "Event"].Rows.Count; intIndex++)
    {
    strBuildingNo = dstData.Tables["Event"].Rows[intIndex]["bdm_seq_BuildingId"].ToString();
    dblBuildLeft = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Left"]) * 38 * 0.0576;
    dblBuildTop = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Top"]) * 38 * 0.0576;
    dblBuildTop = dblBuildTop + 45;
    dblBuildWidth = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Length"]) * 38 * 0.0576;
    dblBuildHeight = Convert.ToDouble(dstData.Tables["Event"].Rows[intIndex]["bdm_num_Breadth"]) * 38 * 0.0576;
    strCaption = dstData.Tables["Event"].Rows[intIndex]["bdm_txt_Caption"].ToString();

    hidSecLBreadth.Value = hidSecLBreadth.Value + "

    ";

    hidSecLBreadth.Value = hidSecLBreadth.Value + "

    " + strCaption + "
    ";

    Code
    hidSecLBreadth.Value = hidSecLBreadth.Value + " ";
    
    if (hidBuildingNumbers.Value == "")
    {
    hidBuildingNumbers.Value = strBuildingNo;
    }
    else
    {
    hidBuildingNumbers.Value = hidBuildingNumbers.Value + "," + strBuildingNo;
    }
    }

     

    Java script part is as follows:I changed the code entirely to work with the code

     

    JavaScript
    function zoomin()
    {
    var strBuildingNos = document.getElementById("hidBuildingNumbers").value;
    var arrBuildingNos = strBuildingNos.split(',');

    for (var i=0; i

    JavaScript
    {
    var BuildingNo = arrBuildingNos[i];
    var strDivBuildingId = "divBuilding" + BuildingNo;
    document.getElementById("hidSecLBreadth").style.position="";
    var strCurrBuildingWidth =parseFloat(document.getElementById(strDivBuildingId).style.width);
    var strCurrBuildingHeight =parseFloat(document.getElementById(strDivBuildingId).style.height);
    var strCurrBuildingTop = parseFloat(document.getElementById(strDivBuildingId).style.top);
    var strCurrBuildingLeft = parseFloat(document.getElementById(strDivBuildingId).style.left);
    // document.getElementById(strDivBuildingId).style.position="";
    document.getElementById(strDivBuildingId).style.position="absolute";
    document.getElementById(strDivBuildingId).style.width = parseFloat(strCurrBuildingWidth) * 20 * 0.06048;
    document.getElementById(strDivBuildingId).style.height = parseFloat(strCurrBuildingHeight) * 20 * 0.06048;
    document.getElementById(strDivBuildingId).style.top = parseFloat(strCurrBuildingTop) * 20 * 0.06048;
    document.getElementById(strDivBuildingId).style.left = parseFloat(strCurrBuildingLeft) * 20 * 0.06048;
    
    
    }
    }
    0
  • 0
    Thanks James it is working fine.Thank you so much. Great work.
    0