Solved

dotnet: declare a linkbutton to make it invisible

Posted on 2004-09-22
21
485 Views
Last Modified: 2012-05-05
<asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
      <ItemTemplate>
      <table>
      <tr>
      <td><%#Container.DataItem("GeboorteDatum")%></td>
      <td>
      <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
        <asp:Linkbutton id="DeleteButton" CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
      </td>
      </tr>


hi,
I need to declare in the code behind the linkbutton=DeleteButton
  Protected WithEvents DeleteButton As ??????

bcs i need to control this button in the code behind to make it sometimes invisible
  DeleteButton.Visible = False
tks

karel
0
Comment
Question by:karel_jespers
  • 11
  • 8
21 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 12123066
private void DeleteButton_Click(object sender, System.EventArgs e)
{
// your code here

}
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12123102
and you can also use Visible=false in HTML itself
0
 
LVL 6

Expert Comment

by:Mike_Metro
ID: 12123222
<asp:Linkbutton CommandName="Edit" Runat="server" text="Edit" Visible="False"></asp:Linkbutton>
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 6

Author Comment

by:karel_jespers
ID: 12125118
tks for you help

but i need to make the linkbutton invisible in the code behind using the visual basic behind the html

to do that i must declare the link button in the basic code *.aspx.vb source

i must declare it therefore

Protected WithEvents DeleteButton As ??????  <=================

how must i declare to access a link button within a datalist

tks
karel
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12125389
Put this in on Page_Load and see

DeleteButton.Visible = False
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12131325
tks for help,
i added the line to the page_load but then i receive an error msg telling met
DeleteButton is not declared
and this is where i m looking for
Protected WithEvents DeleteButton As ??????  <=how must i declare the linkbutton inside a datalist

karel

0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12132780
Can I see your whoel code pls. HTML+Code behind
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12134554
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="vb_InlezenWijzigenDataViaDataset.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <TITLE>WebForm1</TITLE>
      </HEAD>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      <form id="Form1" runat="server">
            <center><asp:checkboxlist id="check1" runat="server" OnSelectedIndexChanged="Check" TextAlign="Right" AutoPostBack="True">
                        <asp:ListItem checked="true">DATABASE => DATASET  klik hier na accept</asp:ListItem>
                        <asp:ListItem>Item 2</asp:ListItem>
                  </asp:checkboxlist><br>
                  <asp:label id="mess" runat="server"></asp:label><br>
                  <asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
                        <ItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td><%#Container.DataItem("Tekst")%></td>
                                          <td><%#Container.DataItem("Naam")%></td>
                                          <td><%#Container.DataItem("GeboorteDatum")%></td>
                                          <td>
                                                <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
                                                <asp:Linkbutton CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
                                          </td>
                                    </tr>
                              </table>
                        </ItemTemplate>
                        <EditItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td>
                                                <asp:Textbox runat="server" id="txtTekst" text='<%#Databinder.Eval(Container.DataItem, "Tekst") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtNaam" text='<%#Databinder.Eval(Container.DataItem, "Naam") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtGeboorteDatum" text='<%#Databinder.Eval(Container.DataItem, "GeboorteDatum") %>' >
                                                </asp:Textbox>
                                          </td>
                                          <td>
                                                <asp:Linkbutton CommandName="Update" Runat="server" text="Update"></asp:Linkbutton></td>
                                    </tr>
                              </table>
                        </EditItemTemplate>
                  </asp:datalist><br>
                  <asp:linkbutton id="acceptbutton" Runat="server" text="Accept"></asp:linkbutton><br>
                  <asp:linkbutton id="cancelbutton" Runat="server" text="Cancel"></asp:linkbutton><br>
                  <asp:linkbutton id="insertbutton" Runat="server" text="Insert=Nieuw record toevoegen"></asp:linkbutton><br>
                  <br>
                  <A onclick="javascript:window.close()" href="#">EXIT</A>
            </center>
      </form>
</HTML>



code behind is very long


Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents mess As System.Web.UI.WebControls.Label
    Protected WithEvents mydatalist As System.Web.UI.WebControls.DataList
    Private conn As SqlConnection
    Private mydataadapter As SqlDataAdapter
    Protected WithEvents acceptbutton As System.Web.UI.WebControls.LinkButton
    Protected WithEvents insertbutton As System.Web.UI.WebControls.LinkButton
    Protected WithEvents cancelbutton As System.Web.UI.WebControls.LinkButton
    Private mydataset As DataSet
    Protected WithEvents check1 As System.Web.UI.WebControls.CheckBoxList

.....
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12134684
Where is deletebutton declared ?
Is it something like

<asp:linkbutton id="deletetbutton" Runat="server" text="Accept"></asp:linkbutton><br>


you speak dutch ?
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135715
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="vb_InlezenWijzigenDataViaDataset.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
      <HEAD>
            <TITLE>WebForm1</TITLE>
      </HEAD>
      <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
      <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
      <meta content="JavaScript" name="vs_defaultClientScript">
      <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
      <form id="Form1" runat="server">
            <center><asp:checkboxlist id="check1" runat="server" OnSelectedIndexChanged="Check" TextAlign="Right" AutoPostBack="True">
                        <asp:ListItem checked="true">DATABASE => DATASET  klik hier na accept</asp:ListItem>
                        <asp:ListItem>Item 2</asp:ListItem>
                  </asp:checkboxlist><br>
                  <asp:label id="mess" runat="server"></asp:label><br>
                  <asp:datalist id="mydatalist" runat="server" OnDeleteCommand="procedures_dataset" OnUpdateCommand="procedures_dataset"
                        OnEditCommand="procedures_dataset" DataKeyField="Id">
                        <ItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td><%#Container.DataItem("Tekst")%></td>
                                          <td><%#Container.DataItem("Naam")%></td>
                                          <td><%#Container.DataItem("GeboorteDatum")%></td>
                                          <td>
                                                <asp:Linkbutton CommandName="Edit" Runat="server" text="Edit"></asp:Linkbutton>
                                                <asp:Linkbutton id="DeleteButton" CommandName="Delete" Runat="server" text="Delete"></asp:Linkbutton>
                                          </td>
                                    </tr>
                              </table>
                        </ItemTemplate>
                        <EditItemTemplate>
                              <table>
                                    <tr>
                                          <td><%#Container.DataItem("Id")%></td>
                                          <td>
                                                <asp:Textbox runat="server" id="txtTekst" text='<%#Databinder.Eval(Container.DataItem, "Tekst") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtNaam" text='<%#Databinder.Eval(Container.DataItem, "Naam") %>' >
                                                </asp:Textbox>
                                                <asp:Textbox runat="server" id="txtGeboorteDatum" text='<%#Databinder.Eval(Container.DataItem, "GeboorteDatum") %>' >
                                                </asp:Textbox>
                                          </td>
                                          <td>
                                                <asp:Linkbutton CommandName="Update" Runat="server" text="Update"></asp:Linkbutton></td>
                                    </tr>
                              </table>
                        </EditItemTemplate>
                  </asp:datalist><br>
                  <asp:linkbutton id="acceptbutton" Runat="server" text="Accept=Wegschrijven van wijzigingen"></asp:linkbutton><br>
                  <asp:linkbutton id="cancelbutton" Runat="server" text="Cancel=Wijzingen annuleren"></asp:linkbutton><br>
                  <asp:linkbutton id="insertbutton" Runat="server" text="Insert=Nieuw record toevoegen"></asp:linkbutton><br>
                  <br>
                  <A onclick="javascript:window.close()" href="#">EXIT</A>
            </center>
      </form>
</HTML>
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135729
in this code , you find it, previous code was from  a wrong version
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12135751
I am lost here

This works perfectly in my machine

private void Page_Load(object sender, System.EventArgs e)
{
DeleteButton.Visible=False                        
}
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12135867
bsc i didnt entered a
   Protected WithEvents DeleteButton As System...
the basic code cannot work with the DeleteButton
I must declare it but dont know how

in your example did you put the html code the same
a linkbutton inside the itemtemplate of a datalist
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143112
Back.Sorry got stuck yesterday. IS it solved yet ?

You have to declare like this

protected System.Web.UI.WebControls.Button Button1;

This is C#
I would get you VB
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143129
VB would be

Protected WithEvents Deletebutton As System.Web.UI.WebControls.Button
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12143842
for one or another reason the linkbutton doesn't becomes unvisible

doesnt i have to put
Public WithEvents Deletebutton As System.Web.UI.WebControls.Button = New System.Web.UI.WebControls.Button



0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12143869
? Didn;t  get u ?
I just hope you have the code in Page _Load

DeleteButton.Visible=False  

come to MSN IM, abhijitg is my id
0
 
LVL 6

Author Comment

by:karel_jespers
ID: 12155997
the code is there but apparently, the button stays visible
0
 
LVL 20

Accepted Solution

by:
jitganguly earned 500 total points
ID: 12159936
Then there must be something else. Can you please post your full code with the latest changes you made
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 12717218
A 'C' Grade ?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Want the count number from this QUery 2 49
Select distinct 25 100
asp syntax 3 50
File download script VBSCRIPT fail on download PPT files 2 52
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question