[RESOLVED] Accessing a button inside an UpdatePanel

Hello,

OnClick event of a button inside and updatepanel doesn't fire

 

<asp:UpdatePanel runat="server" ID="ImageUpdatePanel"    UpdateMode="Conditional">
     <ContentTemplate>
            <asp:Image ID="Image1" runat="server"   />
            <asp:Button runat="server" id="UploadButton" text="Add..." OnClick="UploadButton_Click"/>
      </ContentTemplate>
</asp:UpdatePanel>    Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Dim myPictureUpdatePanel As UpdatePanel = CType(Form1.FindControl("ImageUpdatePanel"), UpdatePanel)
        ' Dim myPictureUploader As FileUpload = CType(myPictureUpdatePanel.FindControl("FileUploadPicture"), FileUpload)

        If FileUploadPicture.HasFile Then
            Try
                Dim filename As String = Path.GetFileName(FileUploadPicture.FileName)
                FileUploadPicture.SaveAs((Server.MapPath("~/img/") + filename))

                Image1.ImageUrl = "~/img/" & FileUploadPicture.FileName

               ErrorMsg.Text = "Upload status: File uploaded!"
            Catch ex As Exception
              ErrorMsg.Text = ("Upload status: The following error occured: " + ex.Message)

            End Try
        End If
    End Sub

any helps will be appreciated




 

UpdateMode="Conditional"
remove this and try.

you may try to use

UpdateMode="Always"

 instead of

 

 

UpdateMode="Conditional"

or just remove UpdateMode="Conditional" and test the buttonclick though conditional updatemode also should fire the click event. please provide the full page code. it might be another codeblock which is preventing this event to be occured.

 

 

 

 

in your code block your click event should be fired. please provide your full page code.

to know about conditional updatepanel you may get interested to read this

http://codeclimber.net.nz/archive/2007/05/24/updatemode-default-value-for-the-updatepanel-is-always.aspx

Thanks for the replies.

removed UpdateMode="Conditional" or changed to "Always" but bone of these worked. It is woking if  i move button to outside of the updatepanel.

 

my .aspx page:

<%@ Page Language="VB" CodeFile="~/PersonelEkle.aspx.vb" Inherits="PersonelEkle" Debug="true" Culture="Tr-tr"  %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript">
    function DisplayDefaultImage(img) { img.src = 'images/noimage.png'; }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Personel Listesi</title>
<link href="layout.css" rel="stylesheet" type="text/css" />
<link href="modal_popup_styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    function ExpandCollapse() {
        var collPanel = $find("CollapsiblePanelExtender1");
        if (collPanel.get_Collapsed())
            collPanel.set_Collapsed(false);
        else
            collPanel.set_Collapsed(true);
    }
</script>
</head>
<body>
<div class="PageWrapper">
  <div class="header">&nbsp;</div><!-- End of Header -->
  <div class="navigation">
    <div id="menu">
        <ul>
            <li><a href="index.html" class="current">Ana Sayfa</a></li>
            <li><a href="services.html">Personel</a></li>
            <li><a href="blog.html">Araçlar</a></li>
            <li><a href="portfolio.html">Görevler</a></li>
            <li><a href="contact.html">Firmalar</a></li>
        </ul>
    </div> <!-- end of menu -->
  </div><!-- end of navigation -->

  
  <div class="columnswrapper">
    <form id="FormPersonelListesi" runat="server">
      <asp:ScriptManager ID="ScriptManagerPersonelListesi" runat="server" />

         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
               <div class="collapsible_panel">
                  <asp:CollapsiblePanelExtender runat="server" ID="CollapsiblePanelExtender1" TargetControlID="MessagesPanel">
    
                  </asp:CollapsiblePanelExtender>
  
                  <asp:Panel ID="MessagesPanel" runat="server">
                        <asp:Label ID="MessagesLabel" runat="server" Text="test" />
                  </asp:Panel>
               </div><!-- End of CollapsiblePanel -->
              <asp:Panel runat="server" ID="panelTitleIntroduction">
                  <div class="messages">
                      <asp:Label ID="DuplicateInsertErrorMsg" runat="server" Text=""></asp:Label>
                  </div>
              </asp:Panel>

                <asp:CollapsiblePanelExtender runat="server" ID="testCPE" TargetControlID="panelTitleIntroduction"
                    ExpandControlID="panelTitleIntroduction" CollapseControlID="panelTitleIntroduction" Collapsed="false">
                </asp:CollapsiblePanelExtender>
        
                <asp:Button ID="btnClick" OnClientClick="ExpandCollapse()" runat="server" Text="Expand/Collapse" />
           </ContentTemplate>
         </asp:UpdatePanel>


<!-- ................................................................................................................-->
<!-- .............   left- Column   .................................................................................-->
<!-- ................................................................................................................-->
<div class="left-column">
   <div class="leftlabels" style="height: 22px;">Adı Soyadı&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Mesleği&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Unvanı&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Şube Müdürlüğü&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Doğum Tarihi&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Doğum Yeri&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Ev Telefonu&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">Cep Telefonu&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 48px;">Adresi&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 48px;">Medeni Hali&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 52px;">Öğrenim Durumu&nbsp&nbsp:&nbsp</div>
   <div class="leftlabels" style="height: 22px;">e-Mail&nbsp&nbsp:&nbsp</div>
</div>
<!-- ................................................................................................................-->
<!-- ..........   End of Left-Column   ..............................................................................-->
<!-- ................................................................................................................-->




<!-- ................................................................................................................-->
<!-- ..........   Left-Middle-Column   ..............................................................................-->
<!-- ................................................................................................................-->

<div class="left-middle-column">
    <div class="rightlabels" style="height: 27px;">
        <asp:TextBox ID="txtAdSoyad" runat="server"  CssClass="textboxes"/>
    </div>
                
     <div class="rightlabels" style="height: 27px;">
         <asp:UpdatePanel ID="UpdatePanelMeslekler" runat="server" UpdateMode="Conditional">
           <ContentTemplate>
              <asp:ComboBox ID="cboMeslekler"  runat="server" CssClass="listboxes"
                 DataSourceID="sdsMeslekler"
                 DataValueField="MeslekID"
                 DataTextField="Meslegi" Width="405" Height="19" BackColor="#e4f2fc" BorderStyle="Solid" BorderColor="#8CC7F2" BorderWidth="1">
              </asp:ComboBox>
           </ContentTemplate>
         </asp:UpdatePanel>
     </div>


                <div class="rightlabels" style="height: 27px;">
                   <asp:UpdatePanel ID="TitlesUpdatePanel" runat="server" UpdateMode="Conditional">
                      <ContentTemplate>
                        <asp:ComboBox ID="cboUnvanlar" runat="server" CssClass="listboxes"
                            DataSourceID="sdsUnvanlar"
                            DataValueField="UnvanID"
                            DataTextField="Unvani" Width="405" Height="19" BackColor="#e4f2fc" BorderStyle="Solid" BorderColor="#8CC7F2" BorderWidth="1">
                        </asp:ComboBox>
                       </ContentTemplate>
                    </asp:UpdatePanel>
                </div>

                <div class="rightlabels" style="height: 27px;">
                   <asp:ComboBox ID="cboSubeMudurlugu"  runat="server" CssClass="listboxes"
                        DataSourceID="sdsSubeMudurlukleri"
                        DataValueField="SubeMudurluguID"
                        DataTextField="SubeMudurlugu" Width="405" Height="19" BackColor="#e4f2fc" BorderStyle="Solid" BorderColor="#8CC7F2" BorderWidth="1">
                    </asp:ComboBox>
                </div>

                <div class="rightlabels" style="height: 27px;">
                    <asp:TextBox ID="txtDogumTarihi" runat="server" CssClass="textboxes"/>
                </div>

                <div class="rightlabels" style="height: 27px;">
                   <asp:ComboBox ID="cboDogumYerleri" runat="server" CssClass="listboxes"
                        DataSourceID="sdsDogumYerleri"
                        DataValueField="DogumYeriID"
                        DataTextField="DogumYeri" Width="405" Height="19" BackColor="#e4f2fc" BorderStyle="Solid" BorderColor="#8CC7F2" BorderWidth="1">
                   </asp:ComboBox>
                </div>

                <div class="rightlabels" style="height: 27px;">
                    <asp:TextBox ID="txtEvTel" runat="server" CssClass="textboxes"/>
                </div>

                <div class="rightlabels" style="height: 27px;">
                    <asp:TextBox ID="txtCepTel" runat="server" CssClass="textboxes"/>
                </div>

                <div class="rightlabels" style="height: 52px;">
                    <asp:TextBox ID="txtAdresi" runat="server"  CssClass="hightextboxes"/>
                </div>


                <div class="rightlabels" style="height: 52px;">
                    <asp:RadioButtonList ID="chkMedeniHali" runat="server"
                         RepeatDirection="Vertical" CssClass="hightextboxes" Width="432" style="margin: 5px 0px 0px 2px;">
                         <asp:ListItem Value="True">&nbsp;&nbsp;Evli</asp:ListItem>
                         <asp:ListItem Value="False">&nbsp;&nbsp;Bekar</asp:ListItem>
                    </asp:RadioButtonList>
                </div>


               <div class="rightlabels" style="height: 52px;">
                    <asp:RadioButtonList ID="chkOgrenimDurumu" runat="server"
                         RepeatDirection="Horizontal" RepeatColumns="3"
                         CssClass="hightextboxes" Width="432" style="margin: 9px 0px 0px 2px;">
                        <asp:ListItem Value="1">&nbsp;&nbsp;İlköğretim</asp:ListItem>
                        <asp:ListItem Value="2">&nbsp;&nbsp;Lise</asp:ListItem>
                        <asp:ListItem Value="3">&nbsp;&nbsp;Yüksek Okul</asp:ListItem>
                        <asp:ListItem Value="4">&nbsp;&nbsp;Üniversite</asp:ListItem>
                        <asp:ListItem Value="5">&nbsp;&nbsp;Master</asp:ListItem>
                        <asp:ListItem Value="6">&nbsp;&nbsp;Doktora</asp:ListItem>
                    </asp:RadioButtonList>
               </div>



                <div class="rightlabels" style="height: 27px;">
                    <asp:TextBox ID="txtEMail" runat="server" CssClass="textboxes" style="margin: 12px 0px 0px 0px; width: 428px;"/>
                </div>
 </div> <!-- xxxxxxxxxxxxxxxxxxxx   END OF LEFT MIDDLE COLUMN   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->

 <!-- ................................................................................................................-->
<!-- ...........   Right-Middle-Column   ............................................................................-->
<!-- ................................................................................................................-->
<div class="right-middle-column">
    <asp:Button ID="btnMeslekler" runat="server" Text="Meslekler" width="110" Height="25"  CssClass="navigationbuttons" style="margin: 31px 0px 0px 0px;"/>
    <asp:Button ID="btnUnvanlar" runat="server" Text="Unvanlar" width="110" Height="25"  CssClass="navigationbuttons" style="margin: 2px 0px 0px 0px;"/>
    
</div><!-- xxxxxxxxxxxxxxxxxxxxx  END OF RIGHT MIDDLE COLUMN     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  -->






<!-- ................................................................................................................-->
<!-- .............   Right-Column   .................................................................................-->
<!-- ................................................................................................................-->
<div class="right-column">
   <div>
    <asp:UpdatePanel runat="server" ID="ImageUpdatePanel" UpdateMode="Always">
       <ContentTemplate>
        <asp:Image ID="Image1" runat="server" Width="120" Height="150"  />
        <asp:Button runat="server" ID="UploadButton" Text="Resmi Ekle" OnClick="UploadButton_Click"/>
        <asp:TextBox ID="TextBoxPhysicalPath" runat="server"></asp:TextBox>
      </ContentTemplate>
   </asp:UpdatePanel>
  </div>
   
    <div class="sondurumuDiv">
       <asp:ListBox ID="listSonDurumu" runat="server" Rows="1" style="margin: 12px 0px 0px 0px; width: 125px;" >
          <asp:ListItem Value="1">Çalışıyor</asp:ListItem>
          <asp:ListItem Value="2">Emekli Oldu</asp:ListItem>
          <asp:ListItem Value="2">Tayin Oldu</asp:ListItem>
       </asp:ListBox>
    </div>

    
    <div>
        <asp:AsyncFileUpload ID="FileUploadPicture" runat="server" Text="Resim Seç" Width="150"  Height="25" />
        <asp:TextBox ID="txtImageType" runat="server" style="visibility: hidden;"/>
    </div>
    <div style="margin: 100px 0px 0px 0px;" >
        <asp:Button ID="btnInsert" runat="server" OnClick="btnInsert_Click" Text="Yeni Kaydı Ekle"  CssClass="navigationbuttons" width="100" Height="24" />
    </div>
   


  </div> <!-- xxxxxxxxxxxxxxxxxxxxx   END OF RIGHT COLUMN    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  -->
</div><!-- xxxxxxxxxxx END OF PAGE WRAPPER   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -->




<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!-- //////////////////////////              POP UP MESLEKLER              ///////////////////////////////////// -->
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<asp:Panel ID="PanelMeslekler" runat="server" Style="display: none">
<asp:UpdatePanel ID="UpdatePanelModalMeslekler" UpdateMode="Conditional" runat="server">
<ContentTemplate>
       <div class="popupTitlebar">Meslekler</div>
        <div class="inner_wrapper">
          <div class="popupBody">
              <asp:ListView ID="ListViewMeslekler"
                   DataSourceID="sdsMesleklerListView"
                   DataKeyNames="MeslekID" runat="server">

                <ItemTemplate>
                   <div class="ItemTemplate_Wrapper">
                       <div class="col-1">
                          <asp:Button ID="btnEditMeslekItemTemp" runat="Server" Text="Düzenle" CommandName="Edit" CssClass="EditDeleteUpdateInsertButtons"/>
                          <asp:Button ID="btnDeleteMeslekItemTemp" runat="server" Text="Sil" CommandName="Delete" OnClientClick="return confirm('Silmek istediğinizden emin misiniz?')" CssClass="EditDeleteUpdateInsertButtons"/>
                       </div>
                       <div class="col-2"><asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Bind("MeslekID") %>' /></div>
                       <div class="col-3"><asp:Label ID="LastNameLabel" runat="Server" Text='<%#Bind("Meslegi") %>' /></div>
                    </div>
                </ItemTemplate>


                <EditItemTemplate>
                    <div class="EditItemTemplate_Wrapper">
                        <div class="EditCol-1">
                            <asp:Button ID="btnUpdateMeslekEditItemTemp" runat="server" CommandName="Update" Text="Güncelle" ButtonCssClass="NavigationButtons"/>&nbsp;
                            <asp:Button ID="btnCancelMeslekEditItemTemp" runat="server" CommandName="Cancel" Text="Vazgeç" ButtonCssClass="NavigationButtons"/>
                        </div>
                        <div class="EditCol-2"><asp:TextBox ID="txtMeslekIDEditItemTemp" runat="server" Text='<%# Bind("MeslekID") %>' MaxLength="50" /></div>
                        <div class="EditCol-3"><asp:TextBox ID="txtMeslegiEditItemTemp" runat="server" Text='<%# Bind("Meslegi") %>' MaxLength="50" /></div>
                    </div>
                </EditItemTemplate>


                <InsertItemTemplate>
                  <div>
                      <asp:TextBox ID="txtAddMeslegiInsertItemTemp" runat="server" Text='<%# Bind("Meslegi") %>' CssClass="InsertTextBoxes"></asp:TextBox>
                      <asp:Button ID="btnInsertNewMeslek_InsertItemTemp" runat="server" Text="Kaydet" Width="80" Height="26" CausesValidation="true" OnClick="btnInsertNewMeslek_InsertItemTemp_Click" />
                      <asp:Button ID="btnCancelNewMeslek_InsertItemTemp" runat="server" Text="Ekleme Modundan Çık" Width="140" Height="26" CausesValidation="true" onClick="btnCancelNewMeslek_InsertItemTemp_Click"/>
                  </div>
                  <div>
                    <asp:Label ID="lblMeslekMessageLabel" ForeColor="Red" runat="server" />
                  </div>
                </InsertItemTemplate>

                <EmptyDataTemplate>
                   <p>
                        Şu anda veritabanında hiç bir unvan girilmemiş. <br />
                        Yeni bir unvan girmek için aşağıdaki butona tıklayınız
                   </p>

                   <asp:Button Text="Yeni Kayıt" ID="btnMeslekAdd" onClick="btnMeslekEkle_Click" runat="server"  Width="120" Height="28" />
                </EmptyDataTemplate>
                <LayoutTemplate>
                     <div class="HeaderTemplate_Wrapper">
                         <div class="header-1"></div>
                         <div class="header-2">MeslekID</div>
                         <div class="header-3">Meslegi</div>
                     </div>
                     <div runat="server" id="itemPlaceholder" style="height: 200px;"></div>
                     <div class="ListviewFooter">
                          <asp:Button Text="Yeni Kayıt" ID="btnMeslekEkle" onClick="btnMeslekEkle_Click" runat="server"  Width="120" Height="28" />
                     </div>
                </LayoutTemplate>
              </asp:ListView>
          <div class="ListviewFooter">
               <asp:DataPager runat="server" ID="DataPager1" PagedControlID="ListViewMeslekler">
                <Fields>
                  <asp:NumericPagerField PreviousPageText="&lt; Prev" NextPageText="Next &gt;"  ButtonCount="10"  NextPreviousButtonCssClass="PrevNext"
                       CurrentPageLabelCssClass="CurrentPage"  NumericButtonCssClass="PageNumber" />
                 </Fields>
                </asp:DataPager>
          </div>


          </div><!-- End of PopUpBody -->
        <div style="text-align: right; margin: 0px;">
            <asp:Button ID="btnUpdateMeslekler" runat="server" Text="Kapat" OnClick="btnUpdateMeslekler_Click"/>
        </div>
     </div><!-- End of Inner Wrapper -->
  </ContentTemplate>
 </asp:UpdatePanel>
</asp:Panel><!-- End of PanelMeslekler -->
<asp:ModalPopupExtender ID="mpeMeslekler" runat="server"
    TargetControlID="btnMeslekler"
    PopupControlID="PanelMeslekler"
    OkControlID="btnMCloseJobs"
    CancelControlID="btnMCloseJobs"
    BackgroundCssClass="ModalPopupBG"
    DropShadow="false">
</asp:ModalPopupExtender>
<asp:Button ID="btnMCloseJobs" runat="server" Style="visibility: hidden" />
<asp:Button ID="btnMCloseFinish" runat="server" Style="visibility: hidden" />







<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<!-- //////////////////////////              POP UP UNVANLAR              ///////////////////////////////////// -->
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<asp:Panel ID="PanelUnvanlar" runat="server" Style="display: none">
<asp:UpdatePanel ID="UP1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
       <div class="popupTitlebar">Unvanlar</div>
        <div class="inner_wrapper">
          <div class="popupBody">
              <asp:ListView ID="UnvanlarListView"
                   DataSourceID="sdsUnvanlarListView"
                   DataKeyNames="UnvanID" runat="server">

                <ItemTemplate>
                   <div class="ItemTemplate_Wrapper">
                       <div class="col-1">
                          <asp:Button ID="EditButton" runat="Server" Text="Düzenle" CommandName="Edit" CssClass="EditDeleteUpdateInsertButtons"/>
                          <asp:Button ID="DeleteButton" runat="server" Text="Sil" CommandName="Delete" OnClientClick="return confirm('Silmek istediğinizden emin misiniz?')" CssClass="EditDeleteUpdateInsertButtons"/>
                       </div>
                       <div class="col-2"><asp:Label ID="FirstNameLabel" runat="Server" Text='<%#Bind("UnvanID") %>' /></div>
                       <div class="col-3"><asp:Label ID="LastNameLabel" runat="Server" Text='<%#Bind("Unvani") %>' /></div>
                    </div>
                </ItemTemplate>


                <EditItemTemplate>
                    <div class="EditItemTemplate_Wrapper">
                        <div class="EditCol-1">
                            <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Güncelle" ButtonCssClass="NavigationButtons"/>&nbsp;
                            <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Vazgeç" ButtonCssClass="NavigationButtons"/>
                        </div>
                        <div class="EditCol-2"><asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("UnvanID") %>' MaxLength="50" /></div>
                        <div class="EditCol-3"><asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("Unvani") %>' MaxLength="50" /></div>
                    </div>
                </EditItemTemplate>


                <InsertItemTemplate>
                  <div>
                      <asp:TextBox ID="txtAddTitle" runat="server" Text='<%# Bind("Unvani") %>' CssClass="InsertTextBoxes"></asp:TextBox>
                      <asp:Button ID="InsertNewTitle" runat="server" Text="Kaydet" Width="80" Height="26" CausesValidation="true" OnClick="InsertNewTitle_Click" />
                      <asp:Button ID="btnCancelAddingTitles" runat="server" Text="Ekleme Modundan Çık" Width="140" Height="26" CausesValidation="true" onClick="CancelInsertMode"/>
                  </div>
                  <div>
                    <asp:Label ID="MessageLabel" ForeColor="Red" runat="server" />
                  </div>
                </InsertItemTemplate>

                <EmptyDataTemplate>
                   <p>
                        Şu anda veritabanında hiç bir unvan girilmemiş. <br />
                        Yeni bir unvan girmek için aşağıdaki butona tıklayınız
                   </p>

                   <asp:Button Text="Yeni Kayıt" ID="btnUnvanEkle" onClick="btnUnvanEkle_Click" runat="server"  Width="120" Height="28" />
                </EmptyDataTemplate>


                <LayoutTemplate>
                     <div class="HeaderTemplate_Wrapper">
                         <div class="header-1"></div>
                         <div class="header-2">UnvanID</div>
                         <div class="header-3">Unvanı</div>
                     </div>
                     
                     <div runat="server" id="itemPlaceholder" style="height: 200px;"></div>

                     <div class="ListviewFooter">
                          <asp:Button Text="Yeni Kayıt" ID="btnUnvanEkle" onClick="btnUnvanEkle_Click" runat="server"  Width="120" Height="28" />
                     </div>
                </LayoutTemplate>
              </asp:ListView>

          <div class="ListviewFooter">
               <asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="UnvanlarListView">
                <Fields>
                  <asp:NumericPagerField
                       PreviousPageText="&lt; Prev"
                       NextPageText="Next &gt;"
                       ButtonCount="10"
                       NextPreviousButtonCssClass="PrevNext"
                       CurrentPageLabelCssClass="CurrentPage"
                       NumericButtonCssClass="PageNumber" />
                 </Fields>
                </asp:DataPager>
        </div> <!-- End of footer -->


       </div><!-- End of PopUpBody -->
        <div style="text-align: right; margin: 0px;">
                <asp:Button ID="btnCloseUnvanlarPopup" runat="server" Text="Kapat" OnClick="UpdateUnvanlar"/>
        </div>
       </div><!-- End of Inner Wrapper -->

  </ContentTemplate>
 </asp:UpdatePanel>
</asp:Panel><!-- End of PanelMeslekler -->
<asp:ModalPopupExtender ID="mpeUnvanlar" runat="server"
    TargetControlID="btnUnvanlar"
    PopupControlID="PanelUnvanlar"
    OkControlID="btnMFinish"
    CancelControlID="btnMClose"
    BackgroundCssClass="ModalPopupBG"
    DropShadow="false">
</asp:ModalPopupExtender>
<asp:Button ID="btnMClose" runat="server" Style="visibility: hidden" />
<asp:Button ID="btnMFinish" runat="server" Style="visibility: hidden" />






<!-- MESLEKLER -->
<asp:SqlDataSource ID="sdsMesleklerListView" runat="server"
        ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip%>"
        DeleteCommand="DELETE FROM [Meslekler] WHERE [MeslekID] = @original_MeslekID AND [Meslegi] = @original_Meslegi"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT [Meslegi], [MeslekID] FROM [Meslekler]"
        UpdateCommand="UPDATE [Meslekler] SET [Meslegi] = @Meslegi WHERE [MeslekID] = @original_MeslekID AND [Meslegi] = @original_Meslegi">
        <DeleteParameters>
            <asp:Parameter Name="original_MeslekID" Type="Int16" />
            <asp:Parameter Name="original_Meslegi" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Meslegi" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Meslegi" Type="String" />
            <asp:Parameter Name="original_MeslekID" Type="Int16" />
            <asp:Parameter Name="original_Meslegi" Type="String" />
        </UpdateParameters>
</asp:SqlDataSource>





<!-- UNVANLAR -->
<asp:SqlDataSource ID="sdsUnvanlarListView" runat="server"
        ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip%>"
        DeleteCommand="DELETE FROM [Unvanlar] WHERE [UnvanID] = @original_UnvanID AND [Unvani] = @original_Unvani"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT [Unvani], [UnvanID] FROM [Unvanlar]"
        UpdateCommand="UPDATE [Unvanlar] SET [Unvani] = @Unvani WHERE [UnvanID] = @original_UnvanID AND [Unvani] = @original_Unvani">
        <DeleteParameters>
            <asp:Parameter Name="original_UnvanID" Type="Int16" />
            <asp:Parameter Name="original_Unvani" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Unvani" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="Unvani" Type="String" />
            <asp:Parameter Name="original_UnvanID" Type="Int16" />
            <asp:Parameter Name="original_Unvani" Type="String" />
        </UpdateParameters>
</asp:SqlDataSource>







<asp:SqlDataSource ID="sdsMeslekler" runat="server"
     ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip %>"
     SelectCommand="SELECT [MeslekID], [Meslegi] FROM [Meslekler]">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsUnvanlar" runat="server"
     ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip %>"
     SelectCommand="SELECT [UnvanID], [Unvani] FROM [Unvanlar]">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsSubeMudurlukleri" runat="server"
     ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip %>"
     SelectCommand="SELECT [SubeMudurluguID], [SubeMudurlugu] FROM [SubeMudurlukleri]">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsDogumYerleri" runat="server"
     ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip %>"
     SelectCommand="SELECT [DogumYeriID], [DogumYeri] FROM [DogumYerleri]">
</asp:SqlDataSource>

<asp:SqlDataSource ID="sdsDeleteCurrentRecord" runat="server"
     ConnectionString="<%$ ConnectionStrings:csAracVeYollukTakip %>"
     DeleteCommand="DELETE FROM [Personel] WHERE [PersonelID] = @PersonelID">
     <DeleteParameters>
        <asp:Parameter Name="PersonelID" Type="Int32" />
    </DeleteParameters>
</asp:SqlDataSource>
</form>
</body>
</html>

and code-behind;

Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Imports System.Data.Common
Imports System.Diagnostics
Imports System
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Drawing
Imports System.Drawing.Imaging

Partial Class PersonelEkle
Inherits System.Web.UI.Page


Public Shared errorMessage As String

Protected Sub btn_Collapse(ByVal sender As Object, ByVal e As EventArgs)
Me.CollapsiblePanelExtender1.Collapsed = False
Me.CollapsiblePanelExtender1.ClientState = "false"
Me.CollapsiblePanelExtender1.Collapsed = True
Me.CollapsiblePanelExtender1.ClientState = "true"
End Sub



Public Sub con_InfoPersonelInsertMessage(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlInfoMessageEventArgs)

DuplicateInsertErrorMsg.Text = e.Message
End Sub




Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If FileUploadPicture.HasFile Then
Try
Dim filename As String = Path.GetFileName(FileUploadPicture.FileName)
FileUploadPicture.SaveAs((Server.MapPath("~/img/") + filename))
Image1.ImageUrl = "~/img/" & FileUploadPicture.FileName
DuplicateInsertErrorMsg.Text = "Upload status: File uploaded!"
Catch ex As Exception
DuplicateInsertErrorMsg.Text = ("Upload status: The following error occured: " + ex.Message)
End Try
End If
End Sub



Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsValid Then Exit Sub
Dim con As SqlConnection = New SqlConnection("server=MYPC\SQLEXPRESS; database=AracVeYollukTakip; uid=sa; Password=sa12345678bul; Trusted_Connection=yes; Connect Timeout=10000")
Dim cmd As SqlCommand = New SqlCommand("addNewPerson", con)
cmd.CommandType = CommandType.StoredProcedure

AddHandler con.InfoMessage, AddressOf con_InfoPersonelInsertMessage

If Me.txtAdSoyad.Text Is Nothing OrElse Me.txtAdSoyad.Text = "" Then
errorMessage = "Adı soyadı doldurulması zorunludur."
Me.txtAdSoyad.Focus()
ShowErrorMessage(errorMessage)
errorMessage = Nothing
Exit Sub
End If

If FileUploadPicture.PostedFile Is Nothing OrElse String.IsNullOrEmpty(FileUploadPicture.PostedFile.FileName) OrElse FileUploadPicture.PostedFile.InputStream Is Nothing Then
errorMessage = "Personelin resmi seçilmedi ! Lütfen bir resim seçiniz !"
ShowErrorMessage(errorMessage)
errorMessage = Nothing
Exit Sub
End If



Dim extension As String = Path.GetExtension(FileUploadPicture.PostedFile.FileName).ToLower()
Dim ImageType As String = Nothing
Select Case extension
Case ".gif"
ImageType = "image/gif"
Case ".jpg", ".jpeg", ".jpe"
ImageType = "image/jpeg"
Case ".png"
ImageType = "image/png"
Case Else
errorMessage = "Resim formatı .jpg, jpeg, jpe, png, veya gif uzantılı olması gerekli !"
ShowErrorMessage(errorMessage)
errorMessage = ""
Exit Sub
End Select

Dim imageBytes(FileUploadPicture.PostedFile.InputStream.Length) As Byte
FileUploadPicture.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)

cmd.Parameters.Add("@AdSoyad", SqlDbType.VarChar, 20).Value = txtAdSoyad.Text
cmd.Parameters.Add("@MeslekID", SqlDbType.SmallInt).Value = cboMeslekler.Text
cmd.Parameters.Add("@UnvanID", SqlDbType.SmallInt).Value = cboUnvanlar.Text
cmd.Parameters.Add("@SubeMudurluguID", SqlDbType.TinyInt).Value = cboSubeMudurlugu.Text

If String.IsNullOrEmpty(txtDogumTarihi.Text) Then
cmd.Parameters.Add("@DogumTarihi", SqlDbType.Date).Value = DBNull.Value
Else
cmd.Parameters.Add("@DogumTarihi", SqlDbType.Date).Value = txtDogumTarihi.Text
End If
cmd.Parameters.Add("@DogumYeriID", SqlDbType.TinyInt).Value = cboDogumYerleri.Text
cmd.Parameters.Add("@EvTel", SqlDbType.NChar).Value = txtEvTel.Text
cmd.Parameters.Add("@CepTel", SqlDbType.NChar).Value = txtCepTel.Text
cmd.Parameters.Add("@Adresi", SqlDbType.VarChar).Value = txtAdresi.Text

If String.IsNullOrEmpty(chkMedeniHali.Text) Then
cmd.Parameters.Add("@MedeniHali", SqlDbType.Bit).Value = DBNull.Value
Else
cmd.Parameters.Add("@MedeniHali", SqlDbType.Bit).Value = chkMedeniHali.Text
End If
If String.IsNullOrEmpty(chkOgrenimDurumu.Text) Then
cmd.Parameters.Add("@OgrenimDurumu", SqlDbType.TinyInt).Value = DBNull.Value
Else
cmd.Parameters.Add("@OgrenimDurumu", SqlDbType.TinyInt).Value = chkOgrenimDurumu.Text
End If

cmd.Parameters.Add("@EMail", SqlDbType.VarChar).Value = txtEMail.Text
cmd.Parameters.Add("@SonDurumu", SqlDbType.TinyInt).Value = listSonDurumu.Text
cmd.Parameters.Add("@ImageType", SqlDbType.VarChar).Value = ImageType
cmd.Parameters.Add("@ImageData", SqlDbType.VarBinary).Value = imageBytes

con.Open()
Try
cmd.ExecuteNonQuery()
errorMessage = "Kayıt işlemi başarılı !"
ShowErrorMessage(errorMessage)
errorMessage = Nothing
Catch SqlEx As SqlException
Dim myError As SqlError
For Each myError In SqlEx.Errors
CType(FormPersonelListesi.FindControl("DuplicateInsertErrorMsg"), Label).Text = myError.Message
Next
Finally
con.Close()
End Try

Response.Redirect(Request.Url.AbsoluteUri)

End Sub





Private Sub ShowErrorMessage(ByVal strMessage As String)
Dim strScript As String = "<script language=JavaScript>"
strScript += "alert(""" & strMessage & """);"
strScript += "</script>"
If (Not ClientScript.IsStartupScriptRegistered("clientScript")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "clientScript", strScript)
End If
End Sub


Protected Sub btnMeslekEkle_Click(ByVal sender As Object, ByVal e As EventArgs)
ListViewMeslekler.InsertItemPosition = InsertItemPosition.LastItem
End Sub


Protected Sub btnCancelNewMeslek_InsertItemTemp_Click(ByVal sender As Object, ByVal e As EventArgs)
ListViewMeslekler.InsertItemPosition = InsertItemPosition.None
End Sub


Protected Sub btnInsertNewMeslek_InsertItemTemp_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsValid Then Exit Sub
Try
Dim con As SqlConnection
con = New SqlConnection("server=MYPC\SQLEXPRESS; database=AracVeYollukTakip; uid=sa; Password=sa12345678bul; Trusted_Connection=yes; Connect Timeout=10000")
AddHandler con.InfoMessage, AddressOf con_InfoJobsMessage

Dim cmd As SqlCommand = New SqlCommand("AddNewJob", con)
cmd.CommandType = CommandType.StoredProcedure
Dim txtAddJob As TextBox = CType(ListViewMeslekler.InsertItem.FindControl("txtAddMeslegiInsertItemTemp"), TextBox)
Dim MessageLabels As Label = CType(ListViewMeslekler.InsertItem.FindControl("lblMeslekMessageLabel"), Label)
cmd.Parameters.Add("@Meslegi", SqlDbType.VarChar, 50).Value = CType(ListViewMeslekler.InsertItem.FindControl("txtAddMeslegiInsertItemTemp"), TextBox).Text
con.Open()

If txtAddJob.Text = "" Or IsNothing(txtAddJob.Text) = True Then
MessageLabels.Text = "Lütfen bu alanı doldurunuz!"
txtAddJob.Focus()
txtAddJob.BackColor = Drawing.Color.Azure
Exit Sub
Else
cmd.ExecuteNonQuery()
ListViewMeslekler.DataBind()
MessageLabels.Text = "veri başarıyla eklendi."
End If
con.Close()
Catch SqlEx As SqlException
Dim myError As SqlError
For Each myError In SqlEx.Errors
CType(ListViewMeslekler.InsertItem.FindControl("lblMeslekMessageLabel"), Label).Text = myError.Message
Next
End Try
End Sub

Public Sub con_InfoJobsMessage(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlInfoMessageEventArgs)
CType(ListViewMeslekler.InsertItem.FindControl("lblMeslekMessageLabel"), Label).Text = e.Message
End Sub


Protected Sub btnUpdateMeslekler_Click(ByVal sender As Object, ByVal e As EventArgs)
If Page.IsPostBack Then
cboMeslekler.DataBind()
Dim UpdatePanelMeslekler As UpdatePanel = CType(FormPersonelListesi.FindControl("UpdatePanelMeslekler"), UpdatePanel)
UpdatePanelMeslekler.Update()
Dim PanelMeslekler As Panel = CType(FormPersonelListesi.FindControl("PanelMeslekler"), Panel)
Dim mpe As AjaxControlToolkit.ModalPopupExtender = CType(PanelMeslekler.FindControl("mpeMeslekler"), AjaxControlToolkit.ModalPopupExtender)
mpe.Hide()
End If
End Sub



Protected Sub btnUnvanEkle_Click(ByVal sender As Object, ByVal e As EventArgs)
UnvanlarListView.InsertItemPosition = InsertItemPosition.LastItem
End Sub


Protected Sub CancelInsertMode(ByVal sender As Object, ByVal e As EventArgs)
UnvanlarListView.InsertItemPosition = InsertItemPosition.None
End Sub


Protected Sub InsertNewTitle_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsValid Then Exit Sub
Try
Dim con As SqlConnection
con = New SqlConnection("server=MYPC\SQLEXPRESS; database=AracVeYollukTakip; uid=sa; Password=sa12345678bul; Trusted_Connection=yes; Connect Timeout=10000")
AddHandler con.InfoMessage, AddressOf con_InfoMessage

Dim cmd As SqlCommand = New SqlCommand("AddNewTitle", con)
cmd.CommandType = CommandType.StoredProcedure
Dim txtAddTitle As TextBox = CType(UnvanlarListView.InsertItem.FindControl("txtAddTitle"), TextBox)
Dim MessageLabels As Label = CType(UnvanlarListView.InsertItem.FindControl("MessageLabel"), Label)
cmd.Parameters.Add("@Unvani", SqlDbType.VarChar, 50).Value = CType(UnvanlarListView.InsertItem.FindControl("txtAddTitle"), TextBox).Text
con.Open()

If txtAddTitle.Text = "" Or IsNothing(txtAddTitle.Text) = True Then
MessageLabels.Text = "Lütfen bu alanı doldurunuz!"
txtAddTitle.Focus()
txtAddTitle.BackColor = Drawing.Color.Azure
Exit Sub
Else
cmd.ExecuteNonQuery()
UnvanlarListView.DataBind()
MessageLabels.Text = "veri başarıyla eklendi."
End If
con.Close()
Catch SqlEx As SqlException
Dim myError As SqlError
For Each myError In SqlEx.Errors
CType(UnvanlarListView.InsertItem.FindControl("MessageLabel"), Label).Text = myError.Message
Next
End Try
End Sub

Public Sub con_InfoMessage(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlInfoMessageEventArgs)
CType(UnvanlarListView.InsertItem.FindControl("MessageLabel"), Label).Text = e.Message
End Sub


Protected Sub UpdateUnvanlar()
If Page.IsPostBack Then
cboUnvanlar.DataBind()
Dim TitlesUpdatePanel As UpdatePanel = CType(FormPersonelListesi.FindControl("TitlesUpdatePanel"), UpdatePanel)
TitlesUpdatePanel.Update()
Dim PanelUnvanlar As Panel = CType(FormPersonelListesi.FindControl("PanelUnvanlar"), Panel)
Dim mpe As AjaxControlToolkit.ModalPopupExtender = CType(PanelUnvanlar.FindControl("mpeUnvanlar"), AjaxControlToolkit.ModalPopupExtender)
mpe.Hide()
End If
End Sub


End Class

thoughts on "[RESOLVED] Accessing a button inside an UpdatePanel"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>