Bonjour,
Désolé, j'aurais du mettre ce message dans la rubirque ASP.NET ...
Je rencontre actuellement un probleme que je ne comprend vraiment pas. Je developpe une Web application en ASP.NET / VB.NET. J'ai créer un formulaire qui contient des textbox, bouton etc ... Je travail sur ses textbox / bouton en code behind, tout va bien.
Depuis ce matin, dès que je rajoute un composant, textbox ou autre, quand je veux y acceder depuis le code behind, j'ai l'erreur 'Textbox' is not declared. It may be inaccessible due to its protection level.
Quelqu'un voit-il pourquoi ?
Voici mon code :
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="~/MakeALoan.asmx" Inherits="IT_RENT.WebForm1" EnableEventValidation="false" ValidateRequest="false" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> <style type="text/css"> .style1 { width: 97px; } .style2 { width: 127px; } .style3 { width: 97px; height: 21px; } .style4 { width: 127px; height: 21px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table style="width: 51%; height: 62px;" align="center"> <tr> <td class="style1"> User ID :</td> <td class="style2"> <asp:TextBox ID="TBUserId" runat="server"></asp:TextBox> </td> <td> <asp:Button ID="BTResolve" runat="server" Text="Resolve" onclick="Button1_Click" /> </td> </tr> <tr> <td class="style1"> First Name : </td> <td class="style2"> <asp:TextBox ID="TBFirstName" runat="server" ReadOnly="True"></asp:TextBox> </td> </tr> <tr> <td class="style3"> Last Name : </td> <td class="style4"> <asp:TextBox ID="TBLastName" runat="server" ReadOnly="True"></asp:TextBox> </td> </tr> <tr> <td class="style3"> Cost Center </td> <td class="style4"> <asp:TextBox ID="TBTest" runat="server" ReadOnly="True"></asp:TextBox> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </asp:Content>
Merci d'avance de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 Imports System.DirectoryServices Public Class WebForm1 Inherits System.Web.UI.Page Public Shared userid_test As String = "" Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load userid_test = "" If Not IsPostBack Then Dim UserID As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name UserID = Replace(UserID, "123\", "") TBUserId.Text = UserID Dim LDAP As New DirectoryEntry("***********") Dim searcher As DirectorySearcher = New DirectorySearcher(LDAP) searcher.PropertiesToLoad.Add("cn") searcher.PropertiesToLoad.Add("givenname") searcher.PropertiesToLoad.Add("sn") searcher.PropertiesToLoad.Add("telephoneNumber") searcher.PropertiesToLoad.Add("mail") searcher.PropertiesToLoad.Add("physicalDeliveryOfficeName") searcher.PropertiesToLoad.Add("SAMAccountName") searcher.PropertiesToLoad.Add("Description") searcher.PropertiesToLoad.Add("department") searcher.PropertiesToLoad.Add("Company") searcher.PropertiesToLoad.Add("displayName") searcher.PropertiesToLoad.Add("l") searcher.PropertiesToLoad.Add("name") searcher.PropertiesToLoad.Add("userPrincipalName") searcher.PropertiesToLoad.Add("mobile") searcher.PropertiesToLoad.Add("extensionAttribute2") searcher.PropertiesToLoad.Add("co") searcher.Filter = "(&(SAMAccountName=" & UserID & ")(objectCategory=user))" Dim results As System.DirectoryServices.SearchResultCollection Try results = searcher.FindAll() Catch ex As Exception Exit Sub End Try Dim result As System.DirectoryServices.SearchResult For Each result In results TBFirstName.Text = Trim(CStr(result.Properties("givenname")(0))) TBLastName.Text = Trim(CStr(result.Properties("sn")(0))) 'C'est ici que j'ai l'erreur. TBTest.text = "test" Next Else test() 'TBFirstName.Text = "on a postback" 'MsgBox("On a un postback") End If End Sub end Class
DeWaRs
Partager