我的标签的文本是不会改变的Page_Load中asp.net [英] My label's text isn't changing on page_load asp.net

查看:152
本文介绍了我的标签的文本是不会改变的Page_Load中asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始看asp.net。我这有code,在VB中工作,但不是在ASP。

I'm just starting out looking at asp.net. I've got this code that works in VB, but not in asp.

我已经把这个在Page_Load:

I've put this in the page_load:

Dim db_con As SqlConnection, ssql As String, db_cmd As SqlCommand, rdr As SqlDataReader
    db_con = New SqlConnection("Data Source=myServer;Initial Catalog=processes;User Id=usrID;Password=mypwd;")
    db_cmd = New SqlCommand()
    ssql = "SELECT * FROM command_table_links WHERE command_id = 1"
    db_con.Open()
    db_cmd.Connection = db_con
    db_cmd.CommandText = ssql
    db_cmd.CommandType = Data.CommandType.Text

    rdr = db_cmd.ExecuteReader()
    rdr.Read()
    If rdr.HasRows Then
        lblTest.Text = "It connected"
    Else
        lblTest.Text = "No Connection"
    End If

    rdr.Close()
    db_con.Close()

任何想法,为什么这不会在asp.net中工作?的问题是,标签是空白的。在只要一所示的形式vb.net中,拉布勒说:它连接。

Any idea why this wouldn't work in asp.net? The issue is that the label is blank. In vb.net as soon as the form is shown, the lable says "It connected".

推荐答案

它必须是:

    保护小组的Page_Load(BYVAL发件人为对象,BYVAL E上System.EventArgs)把手Me.Load

这篇关于我的标签的文本是不会改变的Page_Load中asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆