Note that there are some explanatory texts on larger screens.

plurals
  1. POpage get refresh evenif usercontrol validation is false
    primarykey
    data
    text
    <p>I have usercontrol in which I have written Custom-validation which checks whether the entered data in textbox is correct Location or not.On button click click I have checked (page.IsValid) bit,</p> <p>Even-if validation fails it reload the entire page in which the usercontrol is added</p> <p>the Custom validation look like;</p> <pre><code> &lt;asp:CustomValidator id="CustomValidator1" runat="server" Width="102px" Style="margin-left:37px !important" OnServerValidate="TextValidate" ControlToValidate="txtLocationId" ErrorMessage="Incorrect Location."&gt; &lt;/asp:CustomValidator&gt; </code></pre> <p>In UserControl.aspx.cs :-></p> <pre><code>protected void TextValidate(object source, ServerValidateEventArgs args) { string value = string.Empty; dbconfig.conDatabase2.Open(); SqlCommand cmdsqlcmd = new SqlCommand(); cmdsqlcmd.CommandType = CommandType.Text; string locID = args.Value.ToString(); cmdsqlcmd.CommandText = ""; cmdsqlcmd.Connection = dbconfig.conDatabase2; Object ob = cmdsqlcmd.ExecuteScalar(); if (ob == null) { args.IsValid = false; } else { args.IsValid = true; } } </code></pre> <p>On button Click:</p> <p>protected void goButton_OnClick(object sender, EventArgs e) { if (Page.IsValid) { Code goes here... } }</p> <p>In aspx Page:</p> <pre><code>&lt;%@ Register Src="UserControl/UserControlFilter.ascx" TagName="UserControlFilter" TagPrefix="uc1" %&gt; &lt;html&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;AjaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt; &lt;/AjaxToolkit:ToolkitScriptManager&gt; &lt;asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="300000"&gt; &lt;/asp:Timer&gt; &lt;asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server"&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /&gt; &lt;/Triggers&gt; &lt;ContentTemplate&gt; &lt;div class="locadetail" id="bigtrends" style="border-radius:5px;width: 884px; z-index: 100; border-width: 1px; margin: 10px; height: 398px !important; float: left; background-color: #fff !important;"&gt; &lt;/div&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Kindly let me know if I m going wrong somewhere</p> <p>thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload