Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ASP.NET C# เมื่อกดที่ปุ่ม browse แล้วแสดงภาพทีเลือกไว้



 

ASP.NET C# เมื่อกดที่ปุ่ม browse แล้วแสดงภาพทีเลือกไว้

 



Topic : 076029



โพสกระทู้ ( 37 )
บทความ ( 0 )



สถานะออฟไลน์




อยากให้ท่านผู้รู้ช่วยแนะนำโค้ดให้หน่อยนะครับ
คือผมอยากจะเขียนโค้ด เมื่อเวลาเรากด browse และเลือกไฟล์แล้วก็แสดงรูปภาพที่เราเลือกก่อนที่เราจะกดตกลงครับ
ช่วยหน่อยนะครับ

อัพโหลด



Tag : ASP.NET, Ms SQL Server 2005, Web (ASP.NET), C#







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-23 22:41:30 By : gigclubbeer View : 2109 Reply : 3
 

 

No. 1



โพสกระทู้ ( 37 )
บทความ ( 0 )



สถานะออฟไลน์


อันนี้เป็นโค้ดนะครับ...แต่ไม่รู็จะเขียน script ยังไงครับ


Code (C#)
<html>
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <b>จัดการสอบ</b><br />
    รหัสวิชา <asp:Label ID="lblID_course" runat="server" />
    วิชา <asp:Label ID="lblName_course" runat="server" /> Section.<asp:Label ID="lblSection" runat="server" /><br />
    ภาคเรียนที่ <asp:Label ID="lblterm" runat="server" />/<asp:Label ID="lblterm_year" runat="server" />
       <br /><br />
       <asp:HiddenField ID="hdCode_course" runat="server" />
       <table border="0" runat="server">
        <tr>
            <td>สอบ</td>
            <td> : </td>
            <td><asp:TextBox ID="tbTest" runat="server" /></td>
        </tr>
        <tr>
            <td>เฉลย</td>
            <td> : </td>
            <td>
                <asp:Image ID="Image1" runat="server" /><br />
                <asp:FileUpload ID="flKey" runat="server"/>
            </td>
        </tr>
       </table> 
        <asp:Button ID="Button1" runat="server" Text="ตกลง" OnClick="insert" />
        <asp:Button ID="Button2" runat="server" Text="ยกเลิก" OnClick="uninsert" />
       
        </center>
    </form>
</body>
</html>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-23 22:45:24 By : gigclubbeer
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองใช้ JavaScript ครับ

Code (JavaScript)
<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<form name="frmMain" action="" method="post">
<script language="JavaScript">
	function showPreview(ele)
	{
		document.frmMain.imgAvatar.src=ele.value;
	}
</script>
<input type="file" name="filUpload" OnChange="showPreview(this)">
<input type="submit" name="btnSubmit" value="Submit">
<hr>
<img id="imgAvatar">
</form>
</body>
</html>


Go to : JavaScript Display Preview Images Before Upload
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-24 17:35:41 By : webmaster
 

 

No. 3



โพสกระทู้ ( 37 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้ครับ เพราะว่ามันมี script C# อยูข้างบนก่อนแล้วครับ อันนี้โค้ดเต็มทั้งหมดครับ
Code (C#)
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Import Namespace="System.web.UI"%>
<%@ Import Namespace="System.Web.UI.HtmlControls"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="AForge.Imaging"%>
<%@ Import Namespace="AForge.Imaging.Filters"%>
<%@ Import Namespace="AForge"%>
<%@ Import Namespace="AForge.Math"%>
<%@ Import Namespace="AForge.Math.Geometry"%>
<%@ Import Namespace="System.Drawing"%>
<%@ Import Namespace="System.Drawing.Imaging"%>
<%@ Page Language="C#" Debug="true" %>

<script runat="server">
    SqlConnection objConn = new SqlConnection("Server=MONOJA-PC\\SQLEXPRESS;UID=sa;PASSWORD=1234;database=mydatabases;Max Pool Size=400;Connect Timeout=600;");
    SqlCommand objCmd = new SqlCommand();
    SqlCommand objCmd1 = new SqlCommand();
    SqlCommand objCmd2 = new SqlCommand();
    public void Page_Load(object sender, EventArgs e)
    {
        objConn.Open();

        string sql_course;
        SqlDataReader dtReader;
        sql_course = "select * from course where id_course='" + Request.QueryString["id_course"] + "' and section='" + Request.QueryString["section"] + "' and term='" + Request.QueryString["term"] + "' and term_year='" + Request.QueryString["term_year"] + "'";
        objCmd = new SqlCommand(sql_course, objConn);
        dtReader = objCmd.ExecuteReader();
        dtReader.Read();
        this.hdCode_course.Value = dtReader["code_course"].ToString();
            this.lblID_course.Text = dtReader["id_course"].ToString();
            this.lblName_course.Text = dtReader["name_course"].ToString();
            this.lblSection.Text = dtReader["section"].ToString();
            this.lblterm.Text = dtReader["term"].ToString();
            this.lblterm_year.Text = dtReader["term_year"].ToString();
        dtReader.Close();
        dtReader = null;
    }

    
    void insert(object sender, EventArgs e)
    {
        string name = this.lblID_course.Text + "-" + this.lblterm.Text + "-" + this.lblterm_year.Text;
        DirectoryInfo DirInfo = new DirectoryInfo(Server.MapPath(name));
        DirInfo.Create();

        string path = name + "/";
        this.flKey.SaveAs(Server.MapPath(path + "key_"+flKey.FileName));
        //this.Label1.Text = flKey.FileName;

        String file1 = path + "/key_" + flKey.FileName;
        String file = path + "/test.jpg";
        Bitmap newimage = AForge.Imaging.Image.FromFile(Server.MapPath(file1));
        Bitmap newimage1 = AForge.Imaging.Image.FromFile(Server.MapPath(file1));

        ColorFiltering colorFilter = new ColorFiltering();
        colorFilter.Red = new IntRange(0, 50);
        colorFilter.Green = new IntRange(0, 50);
        colorFilter.Blue = new IntRange(0, 50);
        colorFilter.FillOutsideRange = false;
        newimage = colorFilter.Apply(newimage);

        AdditiveNoise noise = new AdditiveNoise();
        newimage = noise.Apply(newimage);

        int num = 2;
        for (int i = 1; i <= num; i++)
        {
            // create filter
            Blur filter = new Blur();
            // apply the filter
            newimage = filter.Apply(newimage);
        }


        // create grayscale filter (BT709)
        Grayscale filter2 = new Grayscale(0.2125, 0.7154, 0.0721);
        // apply the filter
        newimage = filter2.Apply(newimage);

        // create filter
        Threshold filter1 = new Threshold(100);
        // apply the filter
        newimage = filter1.Apply(newimage);

        GrayscaleToRGB filter3 = new GrayscaleToRGB();
        newimage = filter3.Apply(newimage);

        Invert filter4 = new Invert();
        newimage = filter4.Apply(newimage);

        BlobCounter blobCounter = new BlobCounter();
        blobCounter.ProcessImage(newimage);
        Blob[] blobs = blobCounter.GetObjectsInformation();
        Graphics g = Graphics.FromImage(newimage);
        Pen redPen = new Pen(Color.Red, 2);
        Pen bluePen = new Pen(Color.Blue, 2);
        Pen brownPen = new Pen(Color.Brown, 2);
        Pen yPen = new Pen(Color.OrangeRed, 2);
        Pen gPen = new Pen(Color.Green, 2);
        Pen goPen = new Pen(Color.Gold, 2);

        SimpleShapeChecker shapeChecker = new SimpleShapeChecker();

        int x = 0, y = 0, z = 0, w = 0, n = 0, j = 0, c = 0, c1 = 0, r = 0, rr1 = 0, h = 0, sq = 1, rr = 1, r1 = 0;
        int[] a = new int[4];
        int[] cricle = new int[100];
        int[] cricle1 = new int[100];
        int[] b = new int[50];
        int[] b1 = new int[30];
        int[] bb = new int[30];
        int[] q = new int[1];

        for (int i = 1; i <= blobs.Length; i++)
        {
            //a = new int[5];
            if (blobs[x].Rectangle.X >= blobs[i - 1].Rectangle.X && blobs[x].Rectangle.Y >= blobs[i - 1].Rectangle.Y)
            {
                x = i - 1;
                //a[n]=x;
            }
            if (blobs[y].Rectangle.X <= blobs[i - 1].Rectangle.X && blobs[y].Rectangle.Y <= blobs[i - 1].Rectangle.Y)
            {
                y = i - 1;
                //a[n+1] = x;
            }
            if (blobs[z].Rectangle.X <= blobs[i - 1].Rectangle.X && blobs[z].Rectangle.Y >= blobs[i - 1].Rectangle.Y)
            {
                z = i - 1;
                //a[n+2] = x;
            }
            if (blobs[w].Rectangle.X >= blobs[i - 1].Rectangle.X && blobs[w].Rectangle.Y <= blobs[i - 1].Rectangle.Y)
            {
                w = i - 1;
                //a[n+3] = x;
                //this.Label1.Text = w.ToString();
            }
            if (blobs[h].Rectangle.Width <= blobs[i - 1].Rectangle.Width)
            {
                h = i - 1;
                q[0] = h;
                //this.Label3.Text = q[0].ToString();
            }
        }

        for (j = 0; j <= 3; j++)
        {
            if (j == 0)
            {
                a[j] = x;
                //this.Label10.Text = a[j].ToString();
            }
            if (j == 1)
            {
                a[j] = y;
                //this.Label1.Text = a[j].ToString();
            }
            if (j == 2)
            {
                a[j] = z;
                //this.Label1.Text = a[j].ToString();
            }
            if (j == 3)
            {
                a[j] = w;
                //this.Label1.Text = a[j].ToString();
            }
            //this.Label10.Text = this.Label1.Text + a[j] + "<br>";

        }

        for (int i = 1; i <= blobs.Length; i++, rr++)
        {
            System.Collections.Generic.List<AForge.IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i - 1]);
            if (shapeChecker.IsCircle(edgePoints))
            {
                if ((i - 1) < q[0])
                {
                    g.DrawEllipse(redPen, blobs[i - 1].Rectangle);
                    cricle[c] = (i - 1);
                    //this.Label10.Text = this.Label1.Text + cricle[c] + "<br>";
                    c++;
                }
                else if ((i - 1) > q[0])
                {
                    g.DrawEllipse(brownPen, blobs[i - 1].Rectangle);
                    cricle1[c1] = (i - 1);
                    //this.Label1.Text = this.Label1.Text + cricle1[c1] + "<br>";
                    c1++;
                }
                else { }
            }
            else if ((i - 1) != a[0] && (i - 1) != a[1] && (i - 1) != a[2] && (i - 1) != a[3] && (i - 1) != q[0])
            {
                //this.Label10.Text = blobs[w].Rectangle.Y + "=" + blobs[i - 1].Rectangle.Y;
                if (blobs[w].Rectangle.Y == blobs[i - 1].Rectangle.Y)
                {
                    g.DrawEllipse(goPen, blobs[i - 1].Rectangle);
                    bb[r1] = (i - 1);
                    r1++;
                    //this.Label10.Text = this.Label10.Text + blobs[i - 1].Rectangle.Y + "<br>";
                }
                else
                {
                    if ((i - 1) > q[0])
                    {
                        g.DrawEllipse(bluePen, blobs[i - 1].Rectangle);
                        b[r] = (i - 1);
                        r++;
                        //this.Label1.Text = this.Label1.Text + b[r] + "<br>";
                    }
                    if ((i - 1) < q[0] && blobs[i - 1].Rectangle.Y != blobs[h].Rectangle.Y)
                    {
                        g.DrawEllipse(gPen, blobs[i - 1].Rectangle);
                        b1[rr1] = (i - 1);
                        rr1++;
                    }
                }

            }
            else
            {
                //this.Label2.Text = "error"; 
            }
        }

        foreach (int point in bb)
        {
            foreach (int poin in b1)
            {
                foreach (int cri in cricle)
                {
                    if (poin != a[0] && point != a[0] && cri != a[0])
                    {
                        int col, row;
                        col = blobs[point].Rectangle.X;
                        row = blobs[poin].Rectangle.Y;

                        int center = blobs[cri].Rectangle.X + (blobs[cri].Rectangle.Width / 2);
                        int center1 = blobs[cri].Rectangle.Y + (blobs[cri].Rectangle.Height / 2);

                        int radi = center - blobs[cri].Rectangle.X;

                        int A = row - center1;
                        int B = col - center;

                        double sum_a = Math.Pow(A, 2);
                        double sum_b = Math.Pow(B, 2);
                        double sum = sum_a + sum_b;
                        double C = Math.Sqrt(sum);

                        if (C <= radi)
                        {
                            for (int i = 0; i < bb.Length; i++)
                            {
                                int f = bb[i];
                                if (f != 0 && blobs[point].Rectangle.X == blobs[f].Rectangle.X)
                                {
                                    for (int k = 0; k < b1.Length; k++)
                                    {
                                        int co = b1[k];
                                        if (co != 0 && blobs[poin].Rectangle.Y == blobs[co].Rectangle.Y)
                                        {
                                            if (i >= 12 && i <= 13)
                                            {
                                                if (k == 0)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "1";
                                                }
                                                else if (k == 1)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "2";
                                                }
                                                else if (k == 2)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "3";
                                                }
                                                else if (k == 3)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "4";
                                                }
                                                else if (k == 4)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "5";
                                                }
                                                else if (k == 5)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "6";
                                                }
                                                else if (k == 6)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "7";
                                                }
                                                else if (k == 7)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "8";
                                                }
                                                else if (k == 8)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "9";
                                                }
                                                else if (k == 9)
                                                {
                                                    this.Label6.Text = this.Label6.Text + "0";
                                                }
                                            }
                                            
                                            if (i >= 15 && i <= 16)
                                            {
                                                if (k == 0)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "1";
                                                }
                                                else if (k == 1)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "2";
                                                }
                                                else if (k == 2)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "3";
                                                }
                                                else if (k == 3)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "4";
                                                }
                                                else if (k == 4)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "5";
                                                }
                                                else if (k == 5)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "6";
                                                }
                                                else if (k == 6)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "7";
                                                }
                                                else if (k == 7)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "8";
                                                }
                                                else if (k == 8)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "9";
                                                }
                                                else if (k == 9)
                                                {
                                                    this.Label7.Text = this.Label7.Text + "0";
                                                }
                                            }
                                            if (i >= 18 && i <= 24)
                                            {
                                                if (k == 0)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "1";
                                                }
                                                else if (k == 1)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "2";
                                                }
                                                else if (k == 2)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "3";
                                                }
                                                else if (k == 3)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "4";
                                                }
                                                else if (k == 4)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "5";
                                                }
                                                else if (k == 5)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "6";
                                                }
                                                else if (k == 6)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "7";
                                                }
                                                else if (k == 7)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "8";
                                                }
                                                else if (k == 8)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "9";
                                                }
                                                else if (k == 9)
                                                {
                                                    this.Label8.Text = this.Label8.Text + "0";
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //this.Label6.Text = this.Label8.Text;
        int id_course = Convert.ToInt32(this.lblID_course.Text);
        int id_course1 = Convert.ToInt32(this.Label8.Text);
        int section = Convert.ToInt32(this.lblSection.Text);
        int section1 = Convert.ToInt32(this.Label6.Text);

        if (id_course == id_course1 && section == section1)
        {
            String sql_ct, sql_st, sql_st1, sql_st2, sql_st3, sql_ka, sql_keyans, sql_keya;
           
            int intNumRows;
            sql_ct = "SELECT count(*) FROM style_test where code_course='" + this.hdCode_course.Value + "'";
            objCmd = new SqlCommand(sql_ct, objConn);
            intNumRows = Convert.ToInt32(objCmd.ExecuteScalar());

            int numm = intNumRows + 1;
            //string numb = num.ToString();

            sql_st = "INSERT INTO style_test (id_st,name_st,code_course) " +
               " VALUES " +
               " ('" + numm + "','" + this.tbTest.Text + "','" + this.hdCode_course.Value + "')";

            objCmd = new SqlCommand(sql_st, objConn);
            //objCmd.Connection = objConn;
            //objCmd.CommandText = sql_st;
            //objCmd.CommandType = CommandType.Text;

            try
            {
                objCmd.ExecuteNonQuery();
                this.lblStatus.Text = "Record Inserted";
                this.lblStatus.Visible = true;
            }
            catch (Exception ex)
            {
                this.lblStatus.Visible = true;
                this.lblStatus.Text = "Record can not insert Error (" + ex.Message + ")";
            }
            objCmd = null;

            int intNumRows1;
            sql_ct = "SELECT count(*) FROM key_answer where code_course='"+this.hdCode_course.Value+"'";
            objCmd = new SqlCommand(sql_ct, objConn);
            intNumRows1 = Convert.ToInt32(objCmd.ExecuteScalar());
            int numm1 = intNumRows1 + 1;
                
            sql_st2 = "INSERT INTO key_answer (id_key,id_st,key_answer,series,code_course) " +
           " VALUES " +
           " ('" + numm1 + "','" + numm + "','" + flKey.FileName + "','"+this.Label7.Text+"','"+this.hdCode_course.Value+"')";

            objCmd = new SqlCommand();
            objCmd.Connection = objConn;
            objCmd.CommandText = sql_st2;
            objCmd.CommandType = CommandType.Text;

            try
            {
                objCmd.ExecuteNonQuery();
                this.lblStatus2.Text = "Record Inserted";
                this.lblStatus2.Visible = true;
            }
            catch (Exception ex)
            {
                this.lblStatus2.Visible = true;
                this.lblStatus2.Text = "Record can not insert Error (" + ex.Message + ")";
            }
            objCmd = null;


            foreach (int poin in b)
            {
                foreach (int point in bb)
                {
                    foreach (int cri in cricle1)
                    {
                        //this.Label10.Text = poin.ToString();
                        if (poin != a[0] && point != a[0] && cri != a[0])
                        {
                            int col, row;
                            col = blobs[point].Rectangle.X;
                            row = blobs[poin].Rectangle.Y;

                            int center = blobs[cri].Rectangle.X + (blobs[cri].Rectangle.Width / 2);
                            int center1 = blobs[cri].Rectangle.Y + (blobs[cri].Rectangle.Height / 2);

                            int radi = center - blobs[cri].Rectangle.X;

                            int A = row - center1;
                            int B = col - center;

                            double sum_a = Math.Pow(A, 2);
                            double sum_b = Math.Pow(B, 2);
                            double sum = sum_a + sum_b;
                            double C = Math.Sqrt(sum);

                            if (C <= radi)
                            {
                                for (int i = 0; i < b.Length; i++)
                                {
                                    int f = b[i];
                                    //this.Label4.Text = this.Label4.Text + i + "<br>";
                                    //this.Label9.Text = this.Label9.Text + blobs[poin].Rectangle.Y.ToString() + "=" + blobs[f].Rectangle.Y.ToString() + "<br>";
                                    if (f != 0 && blobs[poin].Rectangle.Y == blobs[f].Rectangle.Y)
                                    {
                                        for (int k = 0; k < bb.Length; k++)
                                        {
                                            int co = bb[k];
                                            if (k >= 0 && k <= 5)
                                            {
                                                if (co != 0 && blobs[point].Rectangle.X == blobs[co].Rectangle.X)
                                                {
                                                    i += 1;
                                                    //k += 1;
                                                    if (k == 1)
                                                    {
                                                        this.Label1.Text = "ก";
                                                    }
                                                    else if (k == 2)
                                                    {
                                                        this.Label1.Text = "ข";
                                                    }
                                                    else if (k == 3)
                                                    {
                                                        this.Label1.Text = "ค";
                                                    }
                                                    else if (k == 4)
                                                    {
                                                        this.Label1.Text = "ง";
                                                    }
                                                    else if (k == 5)
                                                    {
                                                        this.Label1.Text = "จ";
                                                    }
                                                    else { }
                                                }
                                            }

                                            if (k >= 6 && k <= 11)
                                            {
                                                if (co != 0 && blobs[point].Rectangle.X == blobs[co].Rectangle.X)
                                                {
                                                    i = i + 21;
                                                    //k += 1;
                                                    if (k == 7)
                                                    {
                                                        this.Label2.Text = "ก";
                                                    }
                                                    else if (k == 8)
                                                    {
                                                        this.Label2.Text = "ข";
                                                    }
                                                    else if (k == 9)
                                                    {
                                                        this.Label2.Text = "ค";
                                                    }
                                                    else if (k == 10)
                                                    {
                                                        this.Label2.Text = "ง";
                                                    }
                                                    else if (k == 11)
                                                    {
                                                        this.Label2.Text = "จ";
                                                    }
                                                    else { }
                                                }
                                            }

                                            if (k >= 12 && k <= 17)
                                            {
                                                if (co != 0 && blobs[point].Rectangle.X == blobs[co].Rectangle.X)
                                                {
                                                    i += 41;
                                                    //k += 1;
                                                    if (k == 13)
                                                    {
                                                        this.Label3.Text = "ก";
                                                    }
                                                    else if (k == 14)
                                                    {
                                                        this.Label3.Text = "ข";
                                                    }
                                                    else if (k == 15)
                                                    {
                                                        this.Label3.Text = "ค";
                                                    }
                                                    else if (k == 16)
                                                    {
                                                        this.Label3.Text = "ง";
                                                    }
                                                    else if (k == 17)
                                                    {
                                                        this.Label3.Text = "จ";
                                                    }
                                                    else { }
                                                }
                                            }
                                            if (k >= 18 && k <= 23)
                                            {
                                                if (co != 0 && blobs[point].Rectangle.X == blobs[co].Rectangle.X)
                                                {
                                                    i += 61;
                                                    //k += 1;
                                                    if (k == 19)
                                                    {
                                                        this.Label4.Text = "ก";
                                                    }
                                                    else if (k == 20)
                                                    {
                                                        this.Label4.Text = "ข";
                                                    }
                                                    else if (k == 21)
                                                    {
                                                        this.Label4.Text = "ค";
                                                    }
                                                    else if (k == 22)
                                                    {
                                                        this.Label4.Text = "ง";
                                                    }
                                                    else if (k == 23)
                                                    {
                                                        this.Label4.Text = "จ";
                                                    }
                                                    else { }
                                                }
                                            }
                                        }
                                        if (i >= 1 && i <= 20)
                                        {
                                            if (i >= 1 && i <= 9)
                                            {
                                                string ii = "0" + i;
                                                sql_ka = "INSERT INTO key_answer1 (number,ans,id_key,id_st) " +
                                                       " VALUES " +
                                                       " ('" + ii + "','" + this.Label1.Text + "','" + numm1 + "','" + numm + "')";
                                                objCmd1 = new SqlCommand();
                                                objCmd1.Connection = objConn;
                                                objCmd1.CommandText = sql_ka;
                                                objCmd1.CommandType = CommandType.Text;

                                                try
                                                {
                                                    objCmd1.ExecuteNonQuery();
                                                    this.lblStatus1.Text = "Record Inserted";
                                                    this.lblStatus1.Visible = true;
                                                }
                                                catch (Exception ex)
                                                {
                                                    this.lblStatus1.Visible = true;
                                                    this.lblStatus1.Text = "Record can not insert Error (" + ex.Message + ")";
                                                }
                                                //this.Label5.Text = this.Label5.Text + sql_st + "<br />";
                                            }
                                            else 
                                            {
                                                sql_ka = "INSERT INTO key_answer1 (number,ans,id_key,id_st) " +
                                                       " VALUES " +
                                                       " ('" + i + "','" + this.Label1.Text + "','" + numm1 + "','" + numm + "')";
                                                objCmd1 = new SqlCommand();
                                                objCmd1.Connection = objConn;
                                                objCmd1.CommandText = sql_ka;
                                                objCmd1.CommandType = CommandType.Text;

                                                try
                                                {
                                                    objCmd1.ExecuteNonQuery();
                                                    this.lblStatus1.Text = "Record Inserted";
                                                    this.lblStatus1.Visible = true;
                                                }
                                                catch (Exception ex)
                                                {
                                                    this.lblStatus1.Visible = true;
                                                    this.lblStatus1.Text = "Record can not insert Error (" + ex.Message + ")";
                                                }
                                                //this.Label5.Text = this.Label5.Text + sql_st + "<br />";
                                            }
                                        }
                                        if (i >= 21 && i <= 40)
                                        {
                                            sql_ka = "INSERT INTO key_answer1 (number,ans,id_key,id_st) " +
                                                    " VALUES " +
                                                    " ('" + i + "','" + this.Label2.Text + "','" + numm1 + "','" + numm + "')";

                                            objCmd1 = new SqlCommand();
                                            objCmd1.Connection = objConn;
                                            objCmd1.CommandText = sql_ka;
                                            objCmd1.CommandType = CommandType.Text;

                                            try
                                            {
                                                objCmd1.ExecuteNonQuery();
                                                this.lblStatus1.Text = "Record Inserted";
                                                this.lblStatus1.Visible = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                this.lblStatus1.Visible = true;
                                                this.lblStatus1.Text = "Record can not insert Error (" + ex.Message + ")";
                                            }
                                            //this.Label5.Text = this.Label5.Text + sql_st + "<br />";
                                        }
                                        if (i >= 41 && i <= 60)
                                        {
                                            sql_ka = "INSERT INTO key_answer1 (number,ans,id_key,id_st) " +
                                                   " VALUES " +
                                                   " ('" + i + "','" + this.Label3.Text + "','" + numm1 + "','" + numm + "')";
                                            objCmd1 = new SqlCommand();
                                            objCmd1.Connection = objConn;
                                            objCmd1.CommandText = sql_ka;
                                            objCmd1.CommandType = CommandType.Text;

                                            try
                                            {
                                                objCmd1.ExecuteNonQuery();
                                                this.lblStatus1.Text = "Record Inserted";
                                                this.lblStatus1.Visible = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                this.lblStatus1.Visible = true;
                                                this.lblStatus1.Text = "Record can not insert Error (" + ex.Message + ")";
                                            }
                                            //this.Label5.Text = this.Label5.Text + sql_st + "<br />";
                                        }
                                        if (i >= 61 && i <= 80)
                                        {
                                            sql_ka = "INSERT INTO key_answer1 (number,ans,id_key,id_st) " +
                                                   " VALUES " +
                                                   " ('" + i + "','" + this.Label4.Text + "','" + numm1 + "','" + numm + "')";
                                            objCmd1 = new SqlCommand();
                                            objCmd1.Connection = objConn;
                                            objCmd1.CommandText = sql_ka;
                                            objCmd1.CommandType = CommandType.Text;

                                            try
                                            {
                                                objCmd1.ExecuteNonQuery();
                                                this.lblStatus1.Text = "Record Inserted";
                                                this.lblStatus1.Visible = true;
                                            }
                                            catch (Exception ex)
                                            {
                                                this.lblStatus1.Visible = true;
                                                this.lblStatus1.Text = "Record can not insert Error (" + ex.Message + ")";
                                            }
                                            //this.Label5.Text = this.Label5.Text + sql_st + "<br />";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        else
        {
            this.Label5.Text = "กรุณาตรวจสอบข้อมูลใหม่";
        }

        g.Dispose();
       /* newimage1 = newimage;
        newimage1.Save(Server.MapPath(file), ImageFormat.Jpeg);
        //this.img.ImageUrl = file;*/

        
        string idcourse = this.lblID_course.Text;
        string sec = this.lblSection.Text;
        string term = this.lblterm.Text;
        string term_year = this.lblterm_year.Text;
        Response.Redirect("Show_test.aspx?id_course="+idcourse+"&section="+sec+"&term="+term+"&term_year="+term_year);
    }
    
    void Page_UnLoad()
    {
        objConn.Close();
        objConn = null;
    }

    void upload(object sender, EventArgs e)
    {
        this.Image1.ImageUrl = this.flKey.FileName;
    }

    void uninsert(object sender, EventArgs e)
    {
        
        
    }
</script>

<html>
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <b>จัดการสอบ</b><br />
    รหัสวิชา <asp:Label ID="lblID_course" runat="server" />
    วิชา <asp:Label ID="lblName_course" runat="server" /> Section.<asp:Label ID="lblSection" runat="server" /><br />
    ภาคเรียนที่ <asp:Label ID="lblterm" runat="server" />/<asp:Label ID="lblterm_year" runat="server" />
       <br /><br />
       <asp:HiddenField ID="hdCode_course" runat="server" />
       <table border="0" runat="server">
           
        <tr>
            <td>สอบ</td>
            <td> : </td>
            <td><asp:TextBox ID="tbTest" runat="server" /></td>
        </tr>
        <tr>
            <td>เฉลย</td>
            <td> : </td>
            <td>
              <asp:FileUpload ID="flKey" runat="server" OnPreRender="upload" />
               <asp:Image ID="Image1" runat="server" />
            </td>
        </tr>
       </table> 
        <asp:Button ID="Button1" runat="server" Text="ตกลง" OnClick="insert" />
        <asp:Button ID="Button2" runat="server" Text="ยกเลิก" OnClick="uninsert" />
        
        <asp:Label ID="Label8" runat="server" />
        <asp:Label ID="Label6" runat="server" />    
        <asp:Label ID="Label1" runat="server" />   
        <asp:Label id="lblStatus" runat="server" visible="False"></asp:Label>  
        <asp:Label id="lblStatus2" runat="server" visible="False"></asp:Label>
        <asp:Label id="lblStatus1" runat="server" visible="False"></asp:Label> 
         
        <asp:Label ID="Label2" runat="server" />
        <asp:Label ID="Label3" runat="server" />
        <asp:Label ID="Label4" runat="server" />
        <asp:Label ID="Label5" runat="server" />
        
        <asp:Label ID="Label7" runat="server" />
       
        </center>
    </form>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-26 21:57:08 By : gigclubbeer
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ASP.NET C# เมื่อกดที่ปุ่ม browse แล้วแสดงภาพทีเลือกไว้
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่