Reputation: 46
I'm trying to make a website with C#. I've a masterpage and there is a DevExpress DateEdit, 4 DevExpress DropDownLists, one button and one label. I've a method like this:
protected void dropdownNolar_SelectedIndexChanged(object sender, EventArgs e)
{
var halisaha = (from veri in veriler.tum_halisahalars
where veri.Il == dropdownIl.Text &&
veri.Ilce == dropdownIlce.Text &&
veri.Mahalle == dropdownMahalle.Text &&
veri.No == dropdownNolar.Text
select veri).FirstOrDefault();
if (halisaha != null)
if (halisaha.description != null)
lblDescription.Text = halisaha.description;
}
and masterpage's aspx code:
<%@ Master Language="C#" AutoEventWireup="true" EnableViewState="true" CodeBehind="~/masterPage.master.cs" Inherits="HaliSahaKiralama.masterPage" %>
<%@ Register assembly="DevExpress.Web.v14.1, Version=14.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head id="Head1" runat="server">
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="Web Page Maker">
<style type="text/css">
#wrapper {
position:relative;
width: 1127px;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
text-align:left;
top: -2px;
left: 55px;
height: 1000px;
background-color:sandybrown;
}
.auto-style1 {
width: 100%;
height: 912px;
border: 5px solid #FFFFFF;
background-color: #66FF33;
}
.auto-style2 {
height: 792px;
}
.auto-style4 {
height: 130px;
border:thick none white;
}
.auto-style5 {
height: 792px;
width: 237px;
}
</style>
</head>
<body style="margin:0px; height: 1093px; background-color:sandybrown" onload="">
<script type="text/javascript" language="javascript">
</script>
<form id="form1" runat="server">
<div id="wrapper">
<table class="auto-style1">
<tr>
<td class="auto-style4" colspan="2" style="background-color:lightseagreen">
<div style="border-style: none; border-color: inherit; border-width: thick; z-index: 1; left: 8px; top: 9px; position: absolute; height: 130px; width: 1111px;">
<img src="hs2.jpg" style="position:absolute; top: 6px; left: 33px; width: 157px;" alt="" />
<dx:ASPxLabel ID="ASPxLabel6" runat="server" Font-Size="36pt" style="z-index: 1; left: 226px; top: 31px; position: absolute; height: 82px; width: 505px" Text="Bamyacılar Halısaha" Theme="Youthful">
</dx:ASPxLabel>
</div>
</td>
</tr>
<tr>
<td class="auto-style5" style="background-color:darkgreen">
<div style="position:absolute; top: -13px; left: 8px; width: 236px; height: 639px; background-color:transparent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
<dx:ASPxDateEdit ID="date_editTarih" runat="server" Date="2015-03-24" Font-Size="16pt" style="z-index: 1; left: 18px; top: 196px; position: absolute; height: 21px; width: 170px" Theme="Youthful">
</dx:ASPxDateEdit>
<dx:ASPxLabel ID="ASPxLabel1" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 165px; position: absolute" Text="İstediğiniz Tarihi Seçiniz:" Theme="Youthful" ForeColor="White">
</dx:ASPxLabel>
<dx:ASPxComboBox ID="dropdownIl" runat="server" style="z-index: 1; left: 18px; top: 280px; position: absolute; height: 29px; width: 170px" Theme="Youthful" OnSelectedIndexChanged="dropdownIl_SelectedIndexChanged1" NullText="İl Seçiniz!">
</dx:ASPxComboBox>
<dx:ASPxLabel ID="ASPxLabel2" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 478px; position: absolute" Text="Stat Numarasını Seçiniz:" Theme="Youthful" ForeColor="White">
</dx:ASPxLabel>
<dx:ASPxComboBox ID="dropdownIlce" runat="server" style="z-index: 1; left: 17px; top: 353px; position: absolute; height: 29px; width: 170px; bottom: 727px;" Theme="Youthful" OnSelectedIndexChanged="dropdownIlce_SelectedIndexChanged1" NullText="İlçe Seçiniz! ">
</dx:ASPxComboBox>
<dx:ASPxLabel ID="ASPxLabel3" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 249px; position: absolute" Text="İlinizi Seçiniz:" Theme="Youthful" ForeColor="White">
</dx:ASPxLabel>
<dx:ASPxComboBox ID="dropdownMahalle" runat="server" style="z-index: 1; left: 17px; top: 431px; position: absolute; height: 29px; width: 170px" Theme="Youthful" OnSelectedIndexChanged="dropdownMahalle_SelectedIndexChanged1" NullText="Mahalle Seçiniz! ">
</dx:ASPxComboBox>
<dx:ASPxLabel ID="ASPxLabel4" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 322px; position: absolute" Text="İlçenizi Seçiniz:" Theme="Youthful" ForeColor="White">
</dx:ASPxLabel>
<dx:ASPxComboBox ID="dropdownNolar" runat="server" style="z-index: 1; left: 18px; top: 510px; position: absolute; height: 29px; width: 170px" Theme="Youthful" OnSelectedIndexChanged="dropdownNolar_SelectedIndexChanged" NullText="Numara Seçiniz!">
</dx:ASPxComboBox>
<dx:ASPxLabel ID="ASPxLabel5" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 400px; position: absolute" Text="Mahallenizi Seçiniz:" Theme="Youthful" ForeColor="White">
</dx:ASPxLabel>
<dx:ASPxButton ID="BtnMasterPageDevamEt" runat="server" Font-Size="12pt" style="z-index: 1; left: 18px; top: 555px; position: absolute" Text="Devam Et" Theme="PlasticBlue" OnClick="btnClickEski01">
</dx:ASPxButton>
</asp:ContentPlaceHolder>
</div>
<br />
</td>
<td class="auto-style2">
<div style="z-index: 1; left: 257px; top: 144px; position: absolute; height: 784px; width: 862px;background-color:#9ACD32">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<p>
<br />
</p>
<p>
</p>
<p>
</p>
<p>
<dx:ASPxBinaryImage ID="ASPxBinaryImage1" runat="server" style="z-index: 1; left: -237px; top: 443px; position: absolute; height: 109px; width: 155px">
</dx:ASPxBinaryImage>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p style="margin-left: 0px">
</p>
<asp:Label ID="lblDescription" runat="server" ForeColor="White" Font-Names="Comic Sans MS" style="z-index: 1; left: -226px; top: 583px; position: absolute; height: 14px" Text="Açıklama">
</asp:Label>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:ContentPlaceHolder>
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
DropDownLists aren't null, but my label is. Why it happens?
Upvotes: 1
Views: 1111
Reputation: 1208
Looking at your code sample. You are in stage 'Postback event handling'. In that stage all controls should be ready to use.
Question is what might cause this unexpected behavior and how to find out issue? Here is MasterPage run-time behavior:
Question is what went wrong in that flow. Why the control in MasterPage was set to null? *You have added code inside placeholder on MasterPage which will be replace with Content control and can end up with null values.
Hope it will help you.
Upvotes: 2