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 > อยากเอาค่า String จาก CodeBehide ส่งไป Compiler ในหน้า Html ต้องส่งไปยังไงครับ



 

อยากเอาค่า String จาก CodeBehide ส่งไป Compiler ในหน้า Html ต้องส่งไปยังไงครับ

 



Topic : 097001



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



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




Code (VB.NET)
Imports System
Imports System.Net
Imports System.IO
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.Control
Imports System.Configuration
Imports System.Collections
Imports System.Web.Security
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.VisualBasic

Partial Class Permission
    Inherits System.Web.UI.Page
    Dim sql As String
    Dim cmd As SqlCommand
    Dim execsql As New ClsExecDB

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        GentHTML()
    End Sub

    Public Sub GentHTML()

        Dim html As New StringBuilder
        html.AppendLine("<asp:TreeView ID=""TreeView1"" runat=""server"" ShowLines =""True"">")
        html.AppendLine("<Nodes >")
        html.AppendLine("<asp:TreeNode Text=""เว็บบอร์ด"" Value=""เว็บบอร์ด"">")
        html.AppendLine("<asp:TreeNode NavigateUrl=""http://www.pantip.com"" ShowCheckBox=""True"" Text=""pantip"" Value=""1"" >")
        html.AppendLine("</asp:TreeNode>")
        html.AppendLine("</asp:TreeNode>")
        html.AppendLine("</Nodes>")
        html.AppendLine("</asp:TreeView><br />")
        html.AppendLine("<asp:Button ID = ""cmdChrck"" runat =""server"" Text = ""Check"" />")

        Response.Write(html.ToString)

    End Sub

End Class


Code (ASP.Net)
<%@ Page Language="VB" MasterPageFile="~/Doc/Site_Master.master" AutoEventWireup="false"
    CodeFile="Permission.aspx.vb" Inherits="Permission" %>

<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <table>
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0">
                </table>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            
            <td>
 
            <% GentHTML() %>>

            </td>
        </tr>
    </table>
</asp:Content>


สิ่งที่ต้องแสดง

ผมมี Code แบบนี้ แต่พอรันแล้วหน้าว่างไม่ขึ้นอะไรเลย อยากทราบว่าผิดตรงใหน หรือว่าตกอะไรไปรึป่าวครับ



Tag : ASP.NET HTML/CSS, Web (ASP.NET), VB.NET, Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-06-25 10:58:56 By : horseoishi View : 1301 Reply : 10
 

 

No. 1

Guest


ผมมี Code แบบนี้ แต่พอรันแล้วหน้าว่างไม่ขึ้นอะไรเลย อยากทราบว่าผิดตรงใหน หรือว่าตกอะไรไปรึป่าวครับ

จริงหรือ? แต่พอรันแล้วหน้าว่างไม่ขึ้นอะไรเลย (คุณได้รับผลลัพธ์)






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 11:43:32 By : ผ่านมา
 


 

No. 2

Guest


คนเราโกหกแม้กระทั่งตัวเอง "พอรันแล้วหน้าว่างไม่ขึ้นอะไรเลย"
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 11:50:36 By : ผ่านมา
 

 

No. 3



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



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


อ่อ นั้นไม่ใช้ผลลัพธ์ ครับผมลืมบอก ถ้ารันได้ก็จะได้ผลตามนั้น ล่ะ ขอโทษทีครับ
ผลลัพธ์ นั้นผมได้จากลอง debug แล้วเอาค่า html ไปลองรันเอาผลลัพธ์ เฉยๆ
-/\-
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 12:44:20 By : horseoishi
 


 

No. 4

Guest


ผมก็ต้องขอโทษคุณด้วยเช่นกันครับ

http://archive.msdn.microsoft.com/mschart/Release/ProjectReleases.aspx?ReleaseId=4418

ลองดาวโหลดตัว ASP.NET Samples มาดูครับ ผมว่ามันให้มากกว่าคำว่า TreeView เสียอีก
(แตกไฟล์ --> เปิด Project --> ดับเบิลคลิ๊กไฟล์ Default.aspx --> และกดปุ่ม F5 )


รูปตัวอย่างครับ
tc01
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 17:02:03 By : ผ่านมา
 


 

No. 5

Guest


(แตกไฟล์ --> เปิด Project --> ดับเบิลคลิ๊กไฟล์ Default.aspx --> และกดปุ่ม F5 )

แก้ไขเป็น เปิด ChartSamples.sln


[x] ผมศึกษา ASP.NET ด้วยตัวเอง จากตัวอย่างนี้แหละครับ ที่เหลือก็ประยุกต์เอา เล่นแร่แปรธาตุไปเรื่อย
เพื่อหาสไตล์การเขียนเป็นของตัวเองครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 17:25:04 By : ผ่านมา
 


 

No. 6



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



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


ขอบคุณมากครับสำหรับตัวอย่าง ผมลองๆแก้ดูก็ยังไม่ได้ เดี๋ยวผมลองใหม่ล่ะกัน -/\-
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-25 21:40:11 By : horseoishi
 


 

No. 7



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



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

ใน GentHTML() ลองเปลี่ยนไปใช้ HTML Tag แทน ASP.NET Control แล้วใช้ Label รับ

Code (VB.NET)
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Text = GentHTML()
    End Sub

    Public Function GentHTML()
        Return "<ul><li>เว็บบอร์ด<ul><li><input type='checkbox'><a href='http://www.pantip.com'>Pantip</a></li></ul></li></ul>"
    End Function


Code (ASP)
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>


cap

แต่ถ้ายืนยันจะใช้ ASP.NET Control มันต้องแอดลงไปประมานลิ้งก์ข้างล่าง
http://msdn.microsoft.com/en-us/library/kyt0fzt1(v=vs.100).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

คิดว่าที่ทำแบบนี้เพราะจะเก็บแท็กไว้ในฐานข้อมูลแล้วคิวรี่เรียกออกใช่ป่าวครับ งั้นลองเปลี่ยนไปใช้ HTML แทนดูเน้อะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-26 10:07:46 By : C2oWisComing
 


 

No. 8



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

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

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


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-26 10:13:18 By : mr.win
 


 

No. 9



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



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


ถูกต้องแล้วครับผมจะ คิวรี่ แล้วดึงข้อมูลมาวาด Html ซึ่งผมคิดว่ามันง่ายแล้วนำไปใช้ได้อีกเยอะ
ตอนนี้ผมทำอีกวิธีนึง ซึ่งปวดหัวพอสมควร (หรือผมอาจจะมึนไปเองก็เป็นได้) เขียนไปมึนไป
Code (VB.NET)
Imports System
Imports System.Net
Imports System.IO
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.Control
Imports System.Configuration
Imports System.Collections
Imports System.Web.Security
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Microsoft.VisualBasic

Partial Class Permission
    Inherits System.Web.UI.Page
    Dim sql As String
    Dim cmd As SqlCommand
    Dim cmd2 As SqlCommand
    Dim link As String = ""
    Dim lic As String
    Dim str As String
    Dim execsql As New ClsExecDB

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Session("license") = "all"

        If IsPostBack = False Then
            PopulateRootLevel()
            Dim toolbarMasterPage As MasterPage = CType(Me.Master, MasterPage)
        End If
    End Sub
    Private Sub License()
        lic = Session("license")
        Dim myArr As Array = Split(lic, ",")
        Dim i As Integer
        For i = 0 To UBound(myArr)
            If str = "" Then
                str = myArr(i)
            ElseIf str <> "" Then
                str = str & " OR " & " sc.id LIKE " & myArr(i)
            End If
        Next
    End Sub

    Private Sub PopulateRootLevel()
      
        If Session("license").ToString = "all" Then
            sql = "select id,parentid,title,(select count(*) FROM T_MENU " _
                & "WHERE parentid=sc.id) childnodecount FROM T_MENU sc where parentID IS NULL"
        ElseIf Session("license").ToString = "lock" Then
            Response.Cookies("_USER_ID").Value = Nothing
            Response.Cookies("_USER_NAME").Value = Nothing
            Response.Cookies("_USER_FIRST_NAME").Value = Nothing
            Response.Cookies("_DEPT_ID").Value = Nothing
            Response.Cookies("_USER_TYPE").Value = Nothing
            Response.Cookies("_COMPANY").Value = Nothing
            Session("license") = Nothing
            Session("user") = Nothing

            Exit Sub

        Else

            License()

            str = " WHERE (sc.id LIKE " & str & ")"

            sql = "select id,parentid,title,(select count(*) FROM T_MENU "
            sql = sql & "WHERE parentid=sc.id) childnodecount FROM T_MENU sc " & str
            sql = sql & "AND parentID IS NULL"

        End If

        cmd = New SqlCommand(sql)
        Dim ds1 As DataSet = New ClsGetDataInfo()._GetDataset4(cmd, "TbMenu")
        PopulateNodes(ds1.Tables("TbMenu"), TreeView1.Nodes)
    End Sub
    Private Sub PopulateSubLevel(ByVal parentid As Integer, ByVal parentNode As TreeNode)

        If Session("license").ToString = "all" Then
            sql = "select id,parentid,prefix,title,proname,(select count(*) FROM T_MENU " _
                & "WHERE parentid=sc.id) childnodecount FROM T_MENU sc where parentID=@parentID order by seq"
        Else
            License()

            str = " WHERE (sc.id LIKE " & str & ")"


            sql = "select id,parentid,prefix,title,proname,(select count(*) FROM T_MENU "
            sql = sql & "WHERE parentid=sc.id) childnodecount FROM T_MENU sc" & str
            sql = sql & "AND parentID=@parentID order by seq "

        End If

        cmd = New SqlCommand(sql)
        cmd.Parameters.Add("@parentID", SqlDbType.SmallInt).Value = parentid
        Dim ds2 As DataSet = New ClsGetDataInfo()._GetDataset4(cmd, "TbMenuselect")
        PopulateNodes(ds2.Tables("TbMenuselect"), parentNode.ChildNodes)
    End Sub
    Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)

        For Each dr As DataRow In dt.Rows
            Dim tn As New TreeNode()
            tn.Text = dr("title").ToString()
            tn.Value = dr("id").ToString()
            If dr("parentid").ToString() <> "" Then
                tn.ShowCheckBox = True
            End If
            nodes.Add(tn)

            'If node has child nodes, then enable on-demand populating
            tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
        Next
    End Sub

    Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate
        PopulateSubLevel(CInt(e.Node.Value), e.Node)
    End Sub

    Protected Sub cmdChrck_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdChrck.Click
        CheckTree()
    End Sub

    Public Sub CheckTree()

        For Each node As TreeNode In TreeView1.CheckedNodes
            Response.Write("value :" + node.Value)
        Next

    End Sub

    'Public Sub GentHTML()

    '    Dim html As New StringBuilder
    '    html.AppendLine("<asp:TreeView ID=""TreeView1"" runat=""server"" ShowLines =""True"">")
    '    html.AppendLine("<Nodes >")
    '    html.AppendLine("<asp:TreeNode Text=""เว็บบอร์ด"" Value=""เว็บบอร์ด"">")
    '    html.AppendLine("<asp:TreeNode NavigateUrl=""http://www.pantip.com"" ShowCheckBox=""True"" Text=""pantip"" Value=""1"" >")
    '    html.AppendLine("</asp:TreeNode>")
    '    html.AppendLine("</asp:TreeNode>")
    '    html.AppendLine("</Nodes>")
    '    html.AppendLine("</asp:TreeView><br />")
    '    html.AppendLine("<asp:Button ID = ""cmdChrck"" runat =""server"" Text = ""Check"" />")

    '    'Response.Write(html.ToString)

    'End Sub


End Class


Code (ASP)
<%@ Page Language="VB" MasterPageFile="~/Doc/Site_Master.master" AutoEventWireup="false"
    CodeFile="Permission.aspx.vb" Inherits="Permission" %>

<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <table>
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0">
                </table>
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                  <asp:TreeView ID="TreeView1" runat="server" ShowLines ="True">
                </asp:TreeView><br />
                <asp:Button ID = "cmdChrck" runat ="server" Text = "Check" />
             <%--   <div>
                    <% GentHTML()%>
                </div>--%>
            
             <%--   <input id="txtDesc2" name="txtDesc2" type="text" value="<% =ServerValue %>" runat ="server"  />
                </div>--%>
            </td>
        </tr>
    </table>
</asp:Content>



ขอบคุณสำหรับความรู้ดีดี ครับผม
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-26 11:00:19 By : horseoishi
 


 

No. 10



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



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


ต่อจากข้างบนลืมแนบรูป ครับ
แคป

มันก็ ok น้ะแต่ปัญหาคือจะแยก node ออกไปจาก node อีกไม่รุ้เขียนไงล่ะ T^T
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-06-26 11:08:31 By : horseoishi
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : อยากเอาค่า String จาก CodeBehide ส่งไป Compiler ในหน้า Html ต้องส่งไปยังไงครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 04
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 อัตราราคา คลิกที่นี่