23 users online (1 members and 22 guests)  


  Results 1 to 1 of 1

Related

  1. Simple tree    Forum: Javascript Forum
    Replies: 7
  2. Tree structure in HTML    Forum: ASP Forum
    Replies: 0
  3. Check if variable contains binary data    Forum: CGI Perl Forum
    Replies: 1
  1. #1
    nishithkant's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    2

    Binary tree in ASP .net not working in FF

    Hi fr.
    I have a problem with binary tree .the code is below ,its working properly in IE but not working in FF or SAFARI .....Opera etc .Can anybody suggest me solution for this .I need quick reply .please copy the code below and test it OR if U have any other solution then plz Provise...........
    thanks in advance................
    PHP Code:
    <body>
    <
    style type="text/css"></style>
    <
    form id="form1" runat="server">
    <
    div>
    <
    asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
    <
    asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
    left: 360px; position: absolute; top: 16px" 
    Text="show graph" UseSubmitBehavior="False" />
    <
    asp:Label ID="Label1" runat="server" Text="insert NodeID please???"></asp:Label></div>
    </
    form>
    </
    body>


    /////C# code//////////////
    public partial class _Default System.Web.UI.Page
    {
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
    int maxlevelval 0maxnode 0;

    Bitmap objbitmap;
    Size recsize = new Size(9545);
    Graphics objgraphics;
    Font font = new Font(FontFamily.GenericSansSerif, ;
    Pen pen = new Pen(Color.Red2);
    Brush reccolor Brushes.BlueViolet;
    Brush textcolor Brushes.White;
    string selectText;
    protected 
    void Page_Load(object senderEventArgs e)
    {
    }
    protected 
    void Button1_Click(object senderEventArgs e)
    {

    String nodeName "";
    Point lrecpointltextpoint;
    Int32 pid 0level 0;
    //Int32 NodeID=1;
    con.Open();
    //NodeID = Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("NodeId")).ToString());
    selectText "";
    selectText "SELECT * FROM Binarytree2 where NodeID=" TextBox1.Text.Trim();
    //if (TextBox1.Text.Trim() == Session["NodeID"].ToString().Trim())
    //{
    // Response.Write("Match");
    //}
    //else
    //{
    // Response.Write("Not Match");
    //}
    SqlDataReader reader;
    using (reader = new SqlCommand(selectTextcon).ExecuteReader())
    {
    // Make sure we have data
    while (reader.Read())
    {
    level Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("Level")).ToString());
    nodeName reader.GetString(reader.GetOrdinal("NodeName"));
    pid Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("ParentID")).ToString());
    break;
    }
    reader.Close();
    }
    maxlevelval level 2;//4 is for level till we want
    maxnode 8;
    Point ppos;
    objbitmap = new Bitmap((maxnode) * 100, (maxnode 4) * 50);
    objgraphics Graphics.FromImage(objbitmap);
    objgraphics.SmoothingMode SmoothingMode.AntiAlias;
    ppos = new Point((maxnode) / 1005);
    lrecpoint = new Point(ppos.Xppos.Y);
    ltextpoint = new Point(ppos.2ppos.Y);
    Rectangle rect = new Rectangle(lrecpointrecsize);






    objgraphics.DrawRectangle(penrect);
    objgraphics.FillRectangle(reccolorrect);
    objgraphics.DrawString(nodeNamefonttextcolorltextpoint);
    DrawNode(ppospidnodeName);
    Response.Clear();
    objbitmap.Save(this.Response.OutputStreamImageFormat.Jpeg);
    objbitmap.Dispose();
    objgraphics.Dispose();
    con.Close();
    }
    //private void ZoomImage()
    //{
    // Image.GetPixelFormatSize=ImagegGetPixelFormatSize.str


    public void DrawNode(Point pposInt32 pidString nName)
    {
    int totalnode 0updatevar 0;
    Int32 nodeID 0level 0;
    String leftChild ""rightChild ""address ""mobile "";
    Point lchildposrchildposleftlninitposleftlnlastposrightlninitposrightlnlastpos;
    selectText "";
    Point lrecpointltextpointrtextpointrrecpoint;
    selectText "SELECT NodeID,NodeName,LeftChild, RightChild,Level, ParentID, Address,Mobile FROM Binarytree2 WHERE ParentID = " pid "AND NodeName='" nName "'";
    SqlDataReader reader;
    using (reader = new SqlCommand(selectTextcon).ExecuteReader())
    {
    // Make sure we have data
    while (reader.Read())
    {
    nodeID Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("NodeId")).ToString());
    leftChild reader.GetString(reader.GetOrdinal("LeftChild"));
    rightChild reader.GetString(reader.GetOrdinal("RightChild"));
    address reader.GetString(reader.GetOrdinal("Address"));
    mobile reader.GetString(reader.GetOrdinal("Mobile"));
    level Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("Level")).ToString());
    pid Int32.Parse(reader.GetSqlValue(reader.GetOrdinal("ParentID")).ToString());
    break; ;
    }
    reader.Close();




    }
    objgraphics.DrawString(mobilefonttextcolorppos.Xppos.15);
    objgraphics.DrawString(addressfonttextcolorppos.Xppos.30);
    if (
    leftChild != "null" && rightChild != "null" && level <= maxlevelval)
    {
    totalnode maxnode + (int)Math.Pow(2level maxlevelval 2);//3 is for level till we want
    updatevar = (totalnode) / (int)Math.Pow(2level maxlevelval 1) * 100;//3 is for level till we want
    rchildpos = new Point(ppos.updatevarppos.50);


    lchildpos = new Point(ppos.updatevarppos.75);
    lrecpoint = new Point(lchildpos.Xlchildpos.Y);
    ltextpoint = new Point(lchildpos.2lchildpos.Y);
    leftlninitpos = new Point(ppos.50ppos.45);
    leftlnlastpos = new Point(lchildpos.50lchildpos.Y);
    Rectangle lrect = new Rectangle(lrecpointrecsize);
    objgraphics Graphics.FromImage(objbitmap);
    objgraphics.DrawRectangle(penlrect);
    objgraphics.FillRectangle(reccolorlrect);
    objgraphics.DrawString(leftChildfonttextcolorltextpoint);
    objgraphics.DrawLine(penleftlninitposleftlnlastpos);
    DrawNode(lchildposnodeIDleftChild);




    rrecpoint = new Point(rchildpos.Xrchildpos.Y);
    rightlninitpos = new Point(ppos.50ppos.45);
    rightlnlastpos = new Point(rchildpos.50rchildpos.Y);
    rtextpoint = new Point(rchildpos.2rchildpos.Y);
    Rectangle rrect = new Rectangle(rrecpointrecsize);
    objgraphics Graphics.FromImage(objbitmap);
    objgraphics.DrawRectangle(penrrect);
    objgraphics.FillRectangle(reccolorrrect);
    objgraphics.DrawString(rightChildfonttextcolorrtextpoint);
    objgraphics.DrawLine(penrightlninitposrightlnlastpos);


    DrawNode(rchildposnodeIDrightChild);
    }


    else if (
    leftChild != "null" && level <= maxlevelval)
    {
    totalnode maxnode + (int)Math.Pow(2level maxlevelval 2);//3 is for level till we want
    updatevar = (totalnode) / (int)Math.Pow(2level maxlevelval 1) * 100;//3 is for level till we want
    lchildpos = new Point(ppos.updatevarppos.75);
    lrecpoint = new Point(lchildpos.Xlchildpos.Y);
    ltextpoint = new Point(lchildpos.2lchildpos.Y);
    leftlninitpos = new Point(ppos.50ppos.45);
    leftlnlastpos = new Point(lchildpos.50lchildpos.Y);
    Rectangle lrect = new Rectangle(lrecpointrecsize);
    objgraphics.DrawRectangle(penlrect);
    objgraphics.FillRectangle(reccolorlrect);
    objgraphics.DrawString(leftChildfonttextcolorltextpoint);
    objgraphics.DrawLine(penleftlninitposleftlnlastpos);
    DrawNode(lchildposnodeIDleftChild);
    }
    else if (
    rightChild != "null" && level <= maxlevelval)
    {
    totalnode maxnode + (int)Math.Pow(2level maxlevelval 2);//4 is for level till we want
    updatevar = (totalnode) / (int)Math.Pow(2level maxlevelval 1) * 100;//4 is for level till we want
    rchildpos = new Point(ppos.updatevarppos.75);
    rrecpoint = new Point(rchildpos.Xrchildpos.Y);
    rtextpoint = new Point(rchildpos.2rchildpos.Y);
    rightlninitpos = new Point(ppos.50ppos.45);
    rightlnlastpos = new Point(rchildpos.50rchildpos.Y);
    Rectangle rrect = new Rectangle(rrecpointrecsize);
    objgraphics.DrawRectangle(penrrect);
    objgraphics.FillRectangle(reccolorrrect);
    objgraphics.DrawString(rightChildfonttextcolorrtextpoint);
    objgraphics.DrawLine(penrightlninitposrightlnlastpos);
    DrawNode(rchildposnodeIDrightChild);
    }
    }
    protected 
    void TextBox1_TextChanged(object senderEventArgs e)
    {

    //con.Close();
    }


    Last edited by HTML; 04-02-2009 at 05:13 PM. Reason: added code tags



Tags for this Thread