Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

UpdatePanel do not update on first click

$
0
0

Hi,

I have very simple update panel that should change valeu of one cell in database and automaticly replace value on website but it does not, I need it to click it twice so data on website is updated, but even when I click it ones on update date in database is updated, if I refresh page after forst update clisked I get updated info on page, but I need it to bu updated on webpage as soon as once update is clicked, please help, my code is:

.aspx

<%@ Page Title="" Language="VB" MasterPageFile="~/administration/MasterPage.master" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="administration_news_category" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager" runat="server" /><asp:UpdatePanel ID="UpdatePanel8" runat="server" UpdateMode="Conditional" ><ContentTemplate><asp:Label ID="lblName" runat="server" /><asp:TextBox ID="TextBoxName" runat="server" /><asp:LinkButton ID="linkButtonOK" runat="server"><asp:Image ID="ImageOK" runat="server" ImageUrl="~/yes.png" /></asp:LinkButton></ContentTemplate></asp:UpdatePanel></asp:Content>

.vb

Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Data

Partial Class administration_news_category
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim connectionString As String = WebConfigurationManager.ConnectionStrings("xxx").ConnectionString
        Dim selectSQL As String
        selectSQL = "SELECT TOP 1 * FROM tblNewsCategory ORDER BY NAME ASC"
        Dim con As New SqlConnection(connectionString)
        Dim cmd As New SqlCommand(selectSQL, con)
        Dim reader As SqlDataReader

        Try
            con.Open()
            reader = cmd.ExecuteReader()
            Do While reader.Read()
                lblName.Text &= reader("NAME")
            Loop
        Catch Err As Exception
        Finally
            con.Close()
        End Try
    End Sub
    Protected Sub linkButtonOK_Click(sender As Object, e As EventArgs) Handles linkButtonOK.Click
        Dim connectionString As String = WebConfigurationManager.ConnectionStrings("dbHSP-AS").ConnectionString
        Dim updateSQL As String = "UPDATE tblNewsCategory SET NAME=@NAME WHERE ID_NEWS_CATEGORY = " & 3
        Dim con As New SqlConnection(connectionString)
        Dim cmd As New SqlCommand(updateSQL, con)

        cmd.Parameters.AddWithValue("@NAME", TextBoxName.Text)

        Try
            con.Open()
            cmd.ExecuteNonQuery()
        Catch err As Exception
        Finally
            con.Close()
        End Try
        UpdatePanel8.Update()
    End Sub
End Class

Thanks in advace for help
 

 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>