Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear my friends,
When i use update panel or use Validation controls in my project,
they don't work and page reload.

Who knows any thing about this issue??
Posted
Comments
Raje_ 8-Mar-13 5:23am    
the control which is causing postback, did you wrap that control with update panel?
hamid-shrk 8-Mar-13 5:27am    
no, this is my page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Elvatra.test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:TextBox ID="TextBox1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator">

</div>
</form>
</body>
</html>

when i didn't use update panel, the validation controls refreshing my page again

1 solution

try this:
ASP.NET
<asp:updatepanel id="upd" runat="server">
      <contenttemplate>
          <asp:textbox id="TextBox1" runat="server"></asp:textbox>
          <asp:button id="Button1" runat="server" text="Button" />
          <asp:requiredfieldvalidator id="RequiredFieldValidator1"
                                      runat="server"
                                      ControlToValidate="TextBox1"
                                      ErrorMessage="RequiredFieldValidator">
          </asp:requiredfieldvalidator>
    </contenttemplate>
  </asp:updatepanel>


Good luck
 
Share this answer
 
v2
Comments
hamid-shrk 8-Mar-13 5:41am    
I used it but the page refreshed again :(
Raje_ 8-Mar-13 5:49am    
can you post your code with Updatepanel?
hamid-shrk 8-Mar-13 5:51am    
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Elvatra.test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">

<asp:updatepanel id="upd" runat="server" xmlns:asp="#unknown">
<contenttemplate>
<asp:TextBox ID="TextBox1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator">


</div>
</form>
</body>
</html>
Raje_ 8-Mar-13 5:57am    
your code is wrong dear, please check your code. you haven't closed the update panel. also your contenttemplate tag is missing. match your code with this solution properly you will get to know where have you done wrong.
hamid-shrk 8-Mar-13 6:02am    
i think you don't understand my problem,
dear Reje, when i use validation controls, they doesn't work and page refresh.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900