hello, Why when I chose an item from my dropDownList or when I click on a button clears my textBoxes ??
here is my ASP Code
<%@ Page Title="Réparation" Language="C#" MasterPageFile="~/TP/MasterPageTP.master" AutoEventWireup="true" CodeFile="ModifRep.aspx.cs" Inherits="TP_ModifRep" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="content">
<br />
<br />
<h2>Matériels en réparations</h2>
<asp:Panel ID="Panel1" runat="server" align="center">
<table style="border-color: #000099; height: 918px; width: 688px" border="1">
<tr>
<td>
<asp:Label ID="Label18" runat="server" Text="Diagnostique du préstatire"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtSuivi" runat="server" CssClass="TextBox"
Height="94px" Width="288px" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label20" runat="server" Text="Statut"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cmbStatut" runat="server" CssClass="Combobox"
Height="32px" Width="170px" AutoPostBack="True" AppendDataBoundItems="true"
onselectedindexchanged="cmbStatut_SelectedIndexChanged" >
</asp:DropDownList>
<br />
<asp:Label ID="lblErrorSta" runat="server" ForeColor="Red"
Text="Veuillez saisir le statut" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label19" runat="server" Text="Date de récéption du matériel"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtDateReception" runat="server" CssClass="TextBox"
Height="25px" Width="162px"></asp:TextBox>
<asp:CalendarExtender ID="txtDateReception_CalendarExtender" runat="server"
Enabled="True" TargetControlID="txtDateReception">
</asp:CalendarExtender>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label21" runat="server" Text="Nouveau service tag"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtNvSt" runat="server" CssClass="TextBox" Height="25px"
Width="162px"></asp:TextBox>
<asp:Label ID="lblST" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<asp:Button ID="btnValider" runat="server" CssClass="blueButton"
Text="Valider" onclick="btnValider_Click" />
</asp:Panel>
Here is my btnValider Code
protected void btnValider_Click(object sender, EventArgs e)
{
if (cmbStatut.SelectedIndex==2)
{if (string.IsNullOrEmpty(txtNvSt.Text))
{
con.charger("update Materiel set reparation= NULL where serviceTag='" + txtServiceTag.Text + "'", false);
Session["ST"] = txtNvSt.Text;
Response.Redirect("NouveauMAt.aspx");
}
else
{
con.charger("insert into Stocker values('1', '" + txtServiceTag.Text + "')", false);
}
}
else if (cmbStatut.SelectedIndex == 3)
{
con.charger("insert into Stocker values('4', '" + txtServiceTag.Text + "')", false);
Response.Redirect("StockHS.aspx");
}
}
At first it tests the selected index of the dropDownList (cmbStatut), and then it tests if the txtNvSt is empty or not. If it's not empty it has to retrieve the value in the txtNv.Text and put it in a session, after that it redirects me to the specific page.
When I did a debug, I found that the txtNvSt.text="" as well as other textBoxes.
The same thing happends when I chose another item from my DropDownList, it fires an autopostBack and clears all textBoxs
Thank you for your help