Click here to Skip to main content
15,886,724 members

Two sections in the same page

Brainy Girl asked:

Open original thread
hi,

i have a web application with a page that divided into two sections. the first section is a search criteria, and the second section is the result view. the second view contains a table of the result and it is being created dynamically. so when a button click event in the first section fired the second section disappeared because the page is being posted back so it returns to its initial state.

i need these two sections to be separated in a way that when a button clicked in the first section the second section not affected. is this possible or not? if yes how?

thanks,

the vb code:

VB
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
        Dim myScript As String
        Try

            Dim doSearch As New Tracking
            Dim dtResult As New DataTable
            Dim txtvoter As New TextBox
            Dim tableCell As New TableCell
            Dim tblRow As New TableRow
            Dim lblfield As New Label
            Dim options As RadioButton

            Dim i As Integer
            Dim j As Integer


            doSearch.TrackingId = CInt(txtTrackingId.Text)
            dtResult = doSearch.Search
            If doSearch.Found Then
                lblCountNumber.Text = dtResult.Rows.Count.ToString
                lblfield = New Label
                lblfield.Text = "choose"
                lblfield.CssClass = "labels"
                tableCell = New TableCell
                tableCell.BorderStyle = BorderStyle.Solid
                tableCell.BorderColor = Drawing.Color.Black

                tableCell.Controls.Add(lblfield)
                tblRow.Cells.Add(tableCell)
                For i = 0 To dtResult.Rows.Count - 1
                    tableCell = New TableCell
                    tableCell.BorderStyle = BorderStyle.Solid
                    tableCell.BorderColor = Drawing.Color.Black
                    options = New RadioButton
                    options.GroupName = "options"
                    options.ID = "option" + i.ToString
                    options.Text = dtResult.Rows(i)("FormId")
                    options.CssClass = "option"

                    tableCell.Controls.Add(options)
                    tblRow.Cells.Add(tableCell)
                Next
                tblResult.Rows.Add(tblRow)


                For j = 0 To dtResult.Columns.Count - 1
                    tblRow = New TableRow
                    lblfield = New Label
                    lblfield.Text = dtResult.Columns.Item(j).ColumnName
                    lblfield.CssClass = "labels"

                    tableCell = New TableCell
                    tableCell.BorderStyle = BorderStyle.Solid
                    tableCell.BorderColor = Drawing.Color.Black
                    tableCell.Controls.Add(lblfield)
                    tblRow.Cells.Add(tableCell)
                    For i = 0 To dtResult.Rows.Count - 1
                        txtvoter = New TextBox
                        tableCell = New TableCell
                        tableCell.BorderStyle = BorderStyle.Solid
                        tableCell.BorderColor = Drawing.Color.Black
                        txtvoter.Text = dtResult.Rows(i)(j).ToString
                        txtvoter.CssClass = "labels"
                        tableCell.Controls.Add(txtvoter)
                        tblRow.Cells.Add(tableCell)

                    Next
                    tblResult.Rows.Add(tblRow)
                Next

                tblResult.Visible = True
                Session.Contents("tableView") = tblResult

            End If
        Catch ex As Exception
            myScript = "alert(" & ex.Message & ");"
            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "myScript", myScript, True)
        End Try

    End Sub

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
        Dim myScript As String
        Try
            Dim i As Integer
            Dim obj As Object
            Dim formIdOption As RadioButton
            Dim formId As Integer
            Dim trackForm As Tracking

            tblResult = Session.Contents("tableView")

            For i = 1 To tblResult.Rows(0).Cells.Count - 1
                obj = tblResult.Rows(0).Cells(i).Controls(0)
                formIdOption = obj
                If formIdOption.Checked Then
                    formId = CInt(formIdOption.ID)
                    Exit For
                End If
            Next

            trackForm = New Tracking
            trackForm.formId = formId
            trackForm.update()
           
        Catch ex As Exception
          
        End Try

    End Sub


the asp code:

ASP.NET
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Search.aspx.vb" Inherits="Analysis.Search" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="ar" dir="rtl">
<head id="Head1" runat="server">
    
</head>
<body>
    <form id="form1" runat="server">
    <div id="searchView">
    <table id="tblSearch" style="width:100%;">
                        <tr>
                            
                            <td>
                                <asp:Label ID="lblSearch" cssclass="labels" runat="server" Text="search"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtTrackingId" cssclass="labels" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            
                            <td>
                                <asp:Label ID="lblCount" cssclass="labels" runat="server" Text="count"></asp:Label>
                            </td>
                            <td>
                                <asp:Label ID="lblCountNumber" CssClass="labels" runat="server" Text=""></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            
                            <td>
                                <asp:Button ID="btnSearch" cssclass="labels" runat="server" Text="search" />
                            </td>
                            <td>
                                <asp:Button ID="btnSave" cssclass="labels" runat="server" Text="save" />
                            </td>
                        </tr>
                    </table>
 
    </div>
   
    <div class="divtable">
    <asp:table runat="server" ID="tblResult"  Visible="False" >

    </asp:table>
    </div>
    </form>
</body>
</html>
Tags: ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900