Category Archives: CompareValidator

CompareValidator

TextBox with AutoPostBack and CompareValidator validates an invalid value with Tab key

Hello,

On an ASP web page, I have a TextBox with AutoPostBack field and a procedure attached to the TextChanged event.  There is also a CompareValidator attached to this field.

If an invalid value is entered and the Enter key pressed, the error message from the CompareValidator shows, and the TextChanged event does not get triggered, which is fine.

If an invalid value is entered, and the Tab key is pressed, the error message from the CompareValidator shows, then disappear and the TextChanged event gets triggered!!

Why is it doing this, is it by design?  Is there a workaround?  I tried to read the IsValid of the CompareValidator from the TextChanged event, but it is at True, so it’s already too late to cancel the PostBack which seems to happen…

Thanks.

hi,

If your page didn’t set enter submit event . The Enter key pressed and Tab key pressed all can trigger Textchange .

we must  know that validator control only validate the value when submit so in textchange event page.isvalid is always true .

I think js can achieve your purpose , you can set js onchange event and compare the two value of the control and input the result in lable.

Hope this helps

 

Hello,

To have the trigger TextChanged work on both keys is fine, but the TextChanged event is not suppose to trigger if the CompareValidator does not validate the entry!

With the Tab key, an invalid value does not validate briefly, then it is validated anyhow, the validation message disappear, and the event gets triggered!

Why is the CompareValidator not blocking this, as it is with the Enter key?

That’s odd. Can you show your relevant HTML & code?

[RESOLVED]my script shows alert message even both values are same

hi

This is my code

<script type="text/javascript">
    function CheckVal1(){

if ($('[id*=Label8]').val() != $('.myclass1').text())

{

alert('Please Check Batch Quantity');

return false;

}

else

return true ;

}
    
    </script>
    
    
 <script type="text/javascript" language="javascript">

        $(document).ready(function () {
           
            $('.btnClass').mouseover(function () {
               
                CheckVal1();
            });
        });
    </script>

Why this shows aler message though my values are same..

Thanks 

show pls. full code

Please try with Jquery TRim function.

http://api.jquery.com/jQuery.trim/

sameer_khanjit

Please try with Jquery TRim function.

http://api.jquery.com/jQuery.trim/

Would you please post a complete code so that i can check from my side..

Thank you

<script type="text/javascript">
    function CheckVal1(){

if ($.trim($('[id*=Label8]').val()) != $.trim($('.myclass1').text()))

{

alert('Please Check Batch Quantity');

return false;

}

else

return true ;

}
    
    </script>


sameer_khanjit

<script type="text/javascript">
    function CheckVal1(){

if ($.trim($('[id*=Label8]').val()) != $.trim($('.myclass1').text()))

{

alert('Please Check Batch Quantity');

return false;

}

else

return true ;

}
    
    </script>

Still i have same problem after using ur code too.. why??

Please post full code, wil try to findout reason.

sameer_khanjit

Please post full code, wil try to findout reason.

                                            </asp:GridView>

</div>
            </ContentTemplate>
        </asp:UpdatePanel>
        &nbsp;
        <asp:TextBox ID="TextBox7" runat="server" onblur="if(this.value == '')this.value='0';"   Font-Bold="False" ForeColor="Black"
            Style="z-index: 120; left: 435px; position: absolute; top: 98px" TabIndex="1"
            Width="18px" BackColor="#99FFFF" Visible="False"></asp:TextBox>
        <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="TextBox1"
            ControlToValidate="TextBox7" Display="Dynamic" ErrorMessage="Your Arrived Pieces  Is Not Equal To Checked Pieces"
            Font-Names="Palatino Linotype" Style="z-index: 121; left: 357px; position: absolute;
            top: 19px" Type="Integer" ValidationGroup="aa">*</asp:CompareValidator>
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="12pt" ForeColor="#000033" Height="22px" Style="z-index: 122; left: 124px;
            position: absolute; top: 70px">Enter Date</asp:Label>
        <asp:TextBox ID="TextBox8" runat="server" onkeyup="return CopyText();" Style="
            left: 209px; position: absolute; top: 71px; z-index: 123;" TabIndex="1" Width="92px"></asp:TextBox>
        <asp:Label ID="Label5" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="Palatino Linotype"
            Font-Size="14pt" ForeColor="Maroon" Height="26px" Style="z-index: 124; left: 584px;
            position: absolute; top: -8px" Text="Lot Details" Visible="False"></asp:Label>
        <cc1:calendarextender id="CalendarExtender1" runat="server" format="dd-MMM-yyyy"
            popupbuttonid="Image1" targetcontrolid="TextBox8"></cc1:calendarextender>
        <asp:ImageButton ID="Image1" runat="server" ImageUrl="~/cal.png" onkeydown="return (event.keyCode!=13)"
            Style="z-index: 125; left: 310px; position: absolute; top: 65px" TabIndex="89" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox8"
            ErrorMessage="Please Enter Date " Font-Bold="True" Font-Names="@Meiryo" Font-Size="10pt"
            SetFocusOnError="True" Style="z-index: 126; left: 343px; position: absolute;
            top: 74px" ValidationGroup="aa">*</asp:RequiredFieldValidator>
        &nbsp; &nbsp;
        <asp:Panel ID="Panel1" runat="server" Height="255px" ScrollBars="Vertical" Style="z-index: 127;
            left: 544px; position: absolute; top: 19px" Width="209px" Visible="False">
            &nbsp;
        </asp:Panel>
        <asp:Label ID="Label7" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="Palatino Linotype"
            Font-Size="14pt" ForeColor="#000033" Height="26px" Style="z-index: 128; left: 78px;
            position: absolute; top: -70px" Visible="False"></asp:Label>
        &nbsp; &nbsp;&nbsp;
    </div>
   
</asp:Content>

Check and let me know why its not working..?

below code will solve your problem
if ($('[id*=Label8]').text() != $('.myclass1').text())

{

alert('Please Check Batch Pcs');

return false;

}

else

return true ;

}

[RESOLVED]Nested grid + WebUserControl + AjaxFileUpload or RequiredFieldValidator

I’ve created two webusercontrols. Both are CRUD controls that have grids with Textboxes and RequireFieldValidators. Edit and New operations are raised in the screen with AJAX ModalPopupExtenders. One of this use, also, an AjaxFileUpload to upload images.

When I put this controls in a blank aspx all work fine. but, when I put this UserControls in a nested grid, (with two more rows in the root grid), two issues appear.

1.- Edit operation of WebUserControl 1: Two RequiredFieldValidators validate even when the values are right. If I accept the blank page without data, two validators validate fields. If I accept the nested page, (with three rows in the root grid), six validatos
appear. I deleted one row in the root grid and, after try to insert a new row in the child grid, four validators validate fields.  

2.- New operation of WebUserControl 2: Trying to uploading a image in the nested grid of the row number 3 of the root, the control upload image in the nested grid of the first row of the root grid. I added other row in the root grid, and ordered in the first
position and, when I upload an image, always upload in the nested grid of the first row of the root grid.

I don’t upload code because I understand individual controls work fine, even both in the same page.

There are issues related this problem? 

Thanks.

 

Charly

This link http://forums.asp.net/t/1402608.aspx/2/10 solve the problem with nested usercontrols and validators. I added a uniqueid to the validator.validation group.

protected void Page_Init(object sender, EventArgs e)
{
	valsumRequest.ValidationGroup += this.UniqueID;
	RequiredFieldValidator6.ValidationGroup += this.UniqueID;
	CompareValidator8.ValidationGroup += this.UniqueID;
	ibtnAcceptProthesis.ValidationGroup += this.UniqueID;
}

The problem with AjaxFileUpload, ModalPopupExtender and UpdatePanel was solved changing AjaxFileUpload with AsyncFileUpload and adding client script to fill controls, (client events in the AsyncFileupload weren’t executed).

	protected void UploadComplete(object sender, AsyncFileUploadEventArgs e)
	{
		string filename = System.IO.Path.GetFileName(fileUpload1.FileName);
		string completePath = Server.MapPath("~/Upload/") + filename;

		fileUpload1.SaveAs(completePath);
	
		ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Guid.NewGuid().ToString(), "top.$get("" + txtName.ClientID + "").value = '" + e.FileName + "';", true);
		ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Guid.NewGuid().ToString(), "top.$get("" + txtContentType.ClientID + "").value = '" + GetContentType(Server.MapPath("~/Upload/") + filename) + "';", true);
		ScriptManager.RegisterClientScriptBlock(this, this.GetType(), Guid.NewGuid().ToString(), "top.$get("" + txtSize.ClientID + "").value = '" + e.FileSize + "';", true);

		updRequestDocument.Update();
	}
	private string GetContentType(string fileName)
	{
		string contentType = "application/octetstream";
		string ext = System.IO.Path.GetExtension(fileName).ToLower();
		Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
		if (registryKey != null && registryKey.GetValue("Content Type") != null)
		{
			contentType = registryKey.GetValue("Content Type").ToString();
		}
		return contentType;
	}

That’s all. Thank you Chetan

 

[RESOLVED]set the date back to the current date in ajax calender extender using javascript

In need to disable previous date selection from ajax calender extender.

<asp:TextBox ID="txtFromDate" runat="server" CssClass="text_box left w80"></asp:TextBox>
        <asp:ImageButton ID="fromDatePicker" CssClass="datepicker" runat="server" CausesValidation="false"
            ImageUrl="~/images/datepicker.png"></asp:ImageButton>
        <ajaxToolkit:CalendarExtender ID="fromDateCalendarExtender" runat="server" EnabledOnClient="true"
            PopupButtonID="fromDatePicker" TargetControlID="txtFromDate" OnClientDateSelectionChanged="checkForPreviousDate">
        </ajaxToolkit:CalendarExtender>

I am using the below given js function

<script type="text/javascript"> 
        // Do not move this to top script tag..it wil throw js error if moved to top 
            function checkForPreviousDate(sender, args) { 
                if (sender._selectedDate < new Date()) { 
                    alert("You cannot select a day earlier than today!"); 
                    sender._selectedDate = new Date(); 
                    // set the date back to the current date 
                    sender._textbox.set_Value(sender._selectedDate.format(sender._format)); 
 
                     
                } 
            }  
        </script>

But the code to set the date back to current date is not working and it gives a js error- sender._textbox is undefined.

 sender._textbox.set_Value(sender._selectedDate.format(sender._format));

Any idea to set the current date and remove the js error?

Try to use Validators for that . First set culture to the page like

<%@ Page Title="DefaultPage" Language="C#" MasterPageFile="~/SiteMaster.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebProject.Default"
EnableEventValidation="false" Culture="en-AU" %>

Then use two compare validators to keep track of Greater then & Lesser then current date

<asp:TextBox ID="txtFromDate" runat="server" CssClass="text_box left w80"></asp:TextBox>
<asp:ImageButton ID="fromDatePicker" CssClass="datepicker" runat="server" CausesValidation="false"
            ImageUrl="~/images/datepicker.png"></asp:ImageButton>

<ajaxToolkit:CalendarExtender ID="fromDateCalendarExtender" runat="server" EnabledOnClient="true"
            PopupButtonID="fromDatePicker" TargetControlID="txtFromDate" OnClientDateSelectionChanged="checkForPreviousDate">
        </ajaxToolkit:CalendarExtender>

<ajaxToolkit:MaskedEditExtender ID="ME_txtFromDate" runat="server" CultureAMPMPlaceholder="" 
  CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 
  CultureDatePlaceholder="" CultureDecimalPlaceholder="" CultureName="en-AU" 
  CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True" 
  OnFocusCssClass="MaskedEditFocus" DisplayMoney="Left" AcceptNegative="Left"
  Mask="99/99/9999" MaskType="Date" TargetControlID="txtFromDate" ErrorTooltipEnabled="True">
  </ajaxToolkit:MaskedEditExtender>

<asp:CompareValidator ID="CMP_txtFromDateLess" runat="server" ControlToValidate="txtFromDate" 
    Display="Dynamic" ErrorMessage="Date Must Not be less then current date" 
    Operator="LessThan" Type="Date" ></asp:CompareValidator>

<asp:CompareValidator ID="CMP_txtFromDateGreater" runat="server" ControlToValidate="txtFromDate" 
    Display="Dynamic" ErrorMessage="Date Must Not be greater then current date" 
    Operator="GreaterThan" Type="Date" ></asp:CompareValidator>

Then set the value to compare to both the compare validators like

protected void Page_Load(object sender, EventArgs e)
 {
     CMP_txtFromDateLess.ValueToCompare = DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy");
     CMP_txtFromDateGreater.ValueToCompare = DateTime.Now.AddDays(1).ToString("dd/MM/yyyy");
fromDateCalendarExtender.SelectedDate = DateTime.Now.ToString("dd/MM/yyyy");
}

Hi,

Please try the below sample. You can use $find("Calendar1").set_selectedDate(date);

<ajaxToolkit:CalendarExtender ID="calendar1" runat="Server" BehaviorID="Calendar1"  TargetControlID="TextBox1" OnClientDateSelectionChanged="dateselect" />
        <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
        
        <ajaxToolkit:CalendarExtender ID="calendar2" runat="Server" BehaviorID="Calendar2"  TargetControlID="TextBox2"    />
        <asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>

        <script type="text/javascript">

        function dateselect(ev)
        {
          var calendarBehavior1=$find("Calendar1");
          var date=calendarBehavior1._selectedDate;
          var calendarBehavior2=$find("Calendar2");
          calendarBehavior2.set_selectedDate(date);

        }
        </script>

http://forums.asp.net/t/1779939.aspx/1

[RESOLVED]gridview loses data after postback

Hello friends,

       I’m binding the data to datagrid based on the dropdownlist selection. I have converted the fields to template fields and i have a textbox where the user will enter the value. When i click the save button i’m not able to retreive the data from datagrid.
I’m pasting my code here. Please help me out.

<asp:GridView ID="GvCoDetails" runat="server" Width="603px" EnableViewState="true"

AutoGenerateColumns="False" BackColor="White" BorderColor="#DEDFDE"
BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black"
GridLines="Vertical">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:Label ID="LblProduct" runat="server" Text=’<%# Bind("productname") %>’> </asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Unit">
<ItemTemplate>
<asp:Label ID="LblUnit" runat="server" Text=’<%# Bind("unitname") %>’> </asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Packing Size">
<ItemTemplate>
<asp:Label ID="LblPackSize" runat="server" Text=’<%# Bind("packingsize") %>’> </asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Order Qty">
<ItemTemplate>
<asp:Label ID="LblOrdQty" runat="server" Text=’<%# Bind("ordqty") %>’> </asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Delivery Qty">
<ItemTemplate>
<asp:TextBox ID="TxtDelQty" runat="server" Enabled="false" Width="40px" CssClass="txtboxround" Text=’<%# Bind("delqty") %>’></asp:TextBox>

</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Return Qty">
<ItemTemplate>
<asp:TextBox ID="TxtReturnQty" runat="server" MaxLength="4" Width="40px" CssClass="txtboxround" ></asp:TextBox>
<asp:FilteredTextBoxExtender ID="ftbe" runat="server" TargetControlID="TxtReturnQty" FilterType="Numbers"></asp:FilteredTextBoxExtender>
<asp:CompareValidator ID="comValqty" Display="Dynamic" CssClass="required" runat="server" ControlToValidate="TxtReturnQty" ControlToCompare="TxtDelQty" Operator="LessThanEqual" Type="Integer" ErrorMessage="Check Return Qty" SetFocusOnError="true"></asp:CompareValidator>

</ItemTemplate>
</asp:TemplateField>

</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>

and my code behind.

protected void DdlCoNo_SelectedIndexChanged(object sender, EventArgs e)
{
if (DdlCoNo.SelectedValue != "–Select–")
{
SalesReturn.coNo = DdlCoNo.Text;
GvCoDetails.DataSource = SalesReturn.GetCoProductDetails();
GvCoDetails.DataBind();
GvCoDetails.Rows[0].Cells[5].Focus();
hidRowCount.Value = GvCoDetails.Rows.Count.ToString();
}
}

protected void ButSave_Click(object sender, EventArgs e)
{

for (i = 0; i < GvCoDetails.Rows.Count; i++)
{
SalesReturn.productName = GvCoDetails.Rows[i].Cells[0].Text;
SalesReturn.unitName = GvCoDetails.Rows[i].Cells[1].Text;
SalesReturn.packSize = GvCoDetails.Rows[i].Cells[2].Text;

SalesReturn.qty = GvCoDetails.Rows[i].Cells[5].Text;

}

}

Hi

Can you check the row count of the grid view in button save click event.

If grid view contains rows then try the following.

protected void ButSave_Click(object sender, EventArgs e)
{
   for (i = 0; i < GvCoDetails.Rows.Count; i++)
   {
          SalesReturn.productName = ((Label)GvCoDetails.Rows[i].FindControl("LblProduct")).Text
          SalesReturn.unitName = ((Label)GvCoDetails.Rows[i].FindControl("LblUnit")).Text;
          SalesReturn.packSize = ((Label)GvCoDetails.Rows[i].FindControl("LblPackSize")).Text;
          SalesReturn.qty = ((TextBox)GvCoDetails.Rows[i].FindControl("TxtReturnQty")).Text;
    }
}

Thanks a lot Mr.Chandrashekar. Its working fine.

[RESOLVED]Expire Date Field Validation Using Java Script…………….

I have the following text box and an Mask extender which stores Expire date of a Medicine in
MM/yyyy format. I want to check this field whether it is less then today’s date or not.

————————————————————————————————–

<asp:TextBox ID="txtExprDt" runat="server" CssClass="txt" Width="100px"
TabIndex="10"></asp:TextBox>
<cc1:MaskedEditExtender ID="txtExprDt_MaskedEditExtender" runat="server"
CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder=""
CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder=""
CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True"
Mask="99/9999" MaskType="Date" TargetControlID="txtExprDt_Valid">
</cc1:MaskedEditExtender>

————————————————————————————————————————

So, can any one suggest me how to to this using Java Script???????

Why dont you use the MaskedEditValidator which is already avaialble with Ajax Toolkit ? Using this you can set maximumvalue and minimumvalue of dates as well, set the MaximumValue property  to be DateTime.Now from your Codebehind and apply  this on your
MaskExtender.

I can’t Find MaskedEditValidator in my Toolkit. Where can i find that???????????

Thank you Mr.

Ankit Srivastava

Your’e welcome Please mark the post as answered :)

Ansuman Padhy

I want to check this field whether it is less then today’s date or not.

Hi Ansuman Padhy,

Why you want to do this with JavaScript? You can easily perform this action using Validation Control of Asp.Net Compare Validator. Checkout my code

<asp:CompareValidator ID="CompareDate" runat="server" ControlToCompare="txtExpiryDate"
    ControlToValidate="txtStartDate" ErrorMessage="Expiry Date should be less or equal to Start Date"
    Operator="LessThanEqual" Type="Date">
</asp:CompareValidator>

Let me know if any query remains.

Cheers

For this query i have to take another textbox but i don’t want to. I want just a Javascript………..

[RESOLVED]how to add my myclass + myclass1 to check equal or not with label

hi

I have myclass and myclass1 i need to add this then i need to check with label 8

how would be my script…

This is my script

<script type="text/javascript">
    function CheckVal1(){

if ($('[id*=Label8]').text() != $('.myclass1').text())

{

alert('Please Check Batch Pcs');

return false;

}

else

return true ;

}
    
    </script>
    
    
 <script type="text/javascript" language="javascript">

        $(document).ready(function () {
           
            $('.btnClass').mouseover(function () {
               
                CheckVal1();
            });
        });
    </script>

Thanks

Hi,

Check below code:

function CheckVal1(){
    var lbl = $('[id*=Label8]').get(0);
    var cls = $('.myclass1').get(0);
    var lbltxt = (lbl && lbl.textContent) ? lbl.textContent : lbl.innerHTML;
    var clstxt = (cls && cls.textContent) ? cls.textContent : cls.innerHTML;

    if (lbltxt && clstxt && clstxt != lbltxt)
    {
    alert('Please Check Batch Pcs');
    return false;
    }
    else
    return true;
}

if not works enhance it!

raju dasa

Hi,

Check below code:

function CheckVal1(){
    var lbl = $('[id*=Label8]').get(0);
    var cls = $('.myclass1').get(0);
    var lbltxt = (lbl && lbl.textContent) ? lbl.textContent : lbl.innerHTML;
    var clstxt = (cls && cls.textContent) ? cls.textContent : cls.innerHTML;

    if (lbltxt && clstxt && clstxt != lbltxt)
    {
    alert('Please Check Batch Pcs');
    return false;
    }
    else
    return true;
}

if not works enhance it!

Hi…

This is my 

 <asp:Label ID="E" CssClass="myclass1" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

 <asp:Label ID="F" CssClass="myclass2" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

 <asp:Label ID="Label8" runat="server"></asp:Label>

What i need here is

my Label8!=class1+myclass2 how would be my script…?

thank you

Hi,

just add another label,

function CheckVal1(){
    var lbl = $('[id*=Label8]').get(0);
    var cls = $('.myclass1').get(0);
    var cls2 = $('.myclass2').get(0);
    var lbltxt = (lbl && lbl.textContent) ? lbl.textContent : lbl.innerHTML;
    var clstxt = (cls && cls.textContent) ? cls.textContent : cls.innerHTML;
    var cls2txt = (cls2 && cls2.textContent) ? cls2.textContent : cls2.innerHTML;
    
    if (lbltxt && clstxt && cls2txt && lbltxt != (clstxt+cls2txt))
    {
    alert('Please Check Batch Pcs');
    return false;
    }
    else
    return true;
}

if need extra features enhance it!

This is my complete aspx page check why its not working some time myclass2 will be Zero

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="RawToWBC_EIT.aspx.cs" Inherits="RawToWBC_EIT" Title="Raw To WBC/EIT Lot Entry" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript">
$(document).ready(function () {
$("input[type=text][id*=TextBox1],input[type=button][id*=ButtonAdd]").live('keyup', function () {
var sum = 0;
var val = 0;
$("input[type=text][id*=TextBox1]").each(function () {
if (isNaN($(this).val()))
val = 0;
else
val = Number($(this).val());
sum = sum + val;
}, null);
$("span[id*=E]").html(sum);
$("input[id*=hiddenTotal1]").val(sum);
});
});

</script>

<script type="text/javascript">
$(document).ready(function () {
$("input[type=text][id*=TextBox2],input[type=button][id*=ButtonAdd]").live('keyup', function () {
var sum = 0;
var val = 0;
$("input[type=text][id*=TextBox2]").each(function () {
if (isNaN($(this).val()))
val = 0;
else
val = Number($(this).val());
sum = sum + val;
}, null);
$("span[id*=EF]").html(sum);
$("input[id*=hiddenTotal12]").val(sum);
});
});

</script>



 <script type="text/javascript">
    function CheckVal1(){
    var lbl = $('[id*=Label8]').get(0);
    var cls = $('.myclass1').get(0);
    var cls2 = $('.myclass2').get(0);
    var lbltxt = (lbl && lbl.textContent) ? lbl.textContent : lbl.innerHTML;
    var clstxt = (cls && cls.textContent) ? cls.textContent : cls.innerHTML;
    var cls2txt = (cls2 && cls2.textContent) ? cls2.textContent : cls2.innerHTML;
    
    if (lbltxt && clstxt && cls2txt && lbltxt != (clstxt+cls2txt))
    {
    alert('Please Check Batch Pcs');
    return false;
    }
    else
    return true;
}
    
    </script>
    
    
 <script type="text/javascript" language="javascript">

        $(document).ready(function () {
           
            $('.btnClass').mouseover(function () {
               
                CheckVal1();
            });
        });
    </script>


            
    <div style="z-index: 101; left: 4px; width: 1009px; position: absolute; top: 44px;
        height: 502px">
        &nbsp;
        <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="11pt" ForeColor="#000033" Height="21px" Style="z-index: 100; left: 113px;
            position: absolute; top: 3px" Text="Select Lot No "></asp:Label>
         <asp:Label ID="Label9" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="16pt" ForeColor="#000033" Height="29px" Style="font-size: x-large;
            z-index: 101; left: 230px; position: absolute; top: -77px; width: 409px; vertical-align: middle; text-align: center;"
            Text="WBC/EIT/Full Chrome Crust/Semi Chrome Crust Segregation Entry" Width="1025px"></asp:Label>
        &nbsp;
        <asp:TextBox ID="TextBox1" runat="server" Font-Bold="False" ForeColor="Teal" ReadOnly="True"
            Style="z-index: 102; left: 405px; position: absolute; top: 85px" TabIndex="1"
            Width="18px" Visible="False"></asp:TextBox>
        &nbsp;
        <div id="DIV1" onclick="return DIV1_onclick()" style="border-right: teal 1px dotted;
            border-top: teal 1px dotted; left: 344px; border-left: teal 1px dotted;
            width: 224px; border-bottom: teal 1px dotted; position: absolute; top: 49px;
            height: 58px; z-index: 132;">
            &nbsp;
            <asp:Button ID="Button3" runat="server" BackColor="Transparent" BorderColor="Transparent"
                BorderStyle="Dashed"  CssClass="btnClass" BorderWidth="1px" Font-Bold="True" Font-Names="Palatino Linotype"
                Font-Size="10pt" ForeColor="#FFFFFF" Height="40px" OnClick="Button3_Click" Style="z-index: 100;
                left: 115px; background-image: url(images/btn_5.png); position: absolute; top: 9px;
                background-color: transparent" Text="Save" ValidationGroup="aa"
                Width="94px" AccessKey="S" />
            <asp:Button ID="Button2" runat="server" BackColor="Transparent" BorderColor="Transparent"
                BorderStyle="Dashed" BorderWidth="1px" Font-Bold="True" Font-Names="Palatino Linotype"
                Font-Size="10pt" ForeColor="#FFFFFF" Height="40px" OnClick="Button2_Click" Style="z-index: 102;
                left: 13px; background-image: url(images/btn_5.png); position: absolute; top: 7px"
                Text="Refresh" Width="94px" AccessKey="R" />
        </div>
        &nbsp;&nbsp;
        <asp:TextBox ID="TextBox3" runat="server" BackColor="#33FFCC" Style="z-index: 104;
            left: 848px; position: absolute; top: -67px" Visible="False"></asp:TextBox>
        &nbsp; &nbsp;
        <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" AutoPostBack="True"
            DataSourceID="LN" DataTextField="LotNo" DataValueField="LotNo" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
            Style="z-index: 105; left: 209px; position: absolute; top: 3px">
            <asp:ListItem Text="Select"></asp:ListItem>
        </asp:DropDownList>
        <asp:SqlDataSource ID="LN" runat="server" ConnectionString="<%$ ConnectionStrings:CHEMIMSConnectionString %>"
            SelectCommand="Raw_Seg" SelectCommandType="StoredProcedure">
        </asp:SqlDataSource>
        &nbsp;
        <img src="Img/Statistics.png" style="z-index: 129; left: 178px; width: 67px; position: absolute;
            top: -72px; height: 63px" />
        &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
        <img src="images/business_user_info.png" style="z-index: 130; left: 337px; position: absolute;
            top: -9px" id="IMG1" onclick="return IMG1_onclick()" />
        &nbsp;
        <asp:Label ID="Label13" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="Palatino Linotype"
            Font-Size="14pt" ForeColor="Maroon" Height="26px" Style="z-index: 107; left: 404px;
            position: absolute; top: -10px" Text="Supplier Name"></asp:Label>
      
        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="DropDownList1"
            ErrorMessage="Please Select LotNo" Font-Bold="True" Font-Names="@Meiryo" Font-Size="12pt"
            Operator="NotEqual" SetFocusOnError="True" Style="z-index: 108; left: 311px;
            position: absolute; top: 3px" ValidationGroup="aa" ValueToCompare="Select">*</asp:CompareValidator>
        &nbsp;
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List"
            Font-Bold="True" Font-Names="Palatino Linotype" Font-Size="10pt" Style="z-index: 109;
            left: -27px; position: absolute; top: -57px; vertical-align: middle; text-align: center;" ValidationGroup="aa" Height="74px" Width="186px" />
        &nbsp; &nbsp;&nbsp;
        <asp:Label ID="Label11" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="12pt" ForeColor="Teal" Style="z-index: 110; left: 404px; position: absolute;
            top: 14px; text-align: left;" Width="292px" Height="27px"></asp:Label>
        &nbsp;
        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="12pt" ForeColor="#000033" Height="22px" Style="z-index: 111; left: 90px;
            position: absolute; top: 37px">Checked Pieces</asp:Label>
        <asp:Label ID="Label8" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="12pt" ForeColor="Teal" Height="22px" Style="z-index: 112; left: 209px;
            position: absolute; top: 38px"></asp:Label>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div style="text-align: left">
                    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"
                        DynamicLayout="true">
                        <ProgressTemplate>
                            <img src="Img/loading.gif" style="z-index: 125; left: 176px; width: 271px; position: absolute;
                                top: 114px; height: 248px" />
                            <div>
                            </div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                    <asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False" Font-Bold="True"
                        Font-Names="Palatino Linotype" Font-Size="12pt" ForeColor="Teal" GridLines="None"
                        OnRowCreated="Gridview1_RowCreated" OnRowDataBound="Gridview1_RowDataBound"
                        SelectedIndex="0" ShowFooter="True" Style="left: 2px; position: absolute; top: 113px; height: 152px" >
                        <Columns>
                            <asp:BoundField DataField="RowNumber" HeaderText="SI No">
                                <ItemStyle Font-Size="Small" />
                                <HeaderStyle ForeColor="Green" HorizontalAlign="Left" />
                            </asp:BoundField>
                           
                            <asp:TemplateField HeaderText="Recevied Pieces">
                             
                                <ItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" TabIndex="7" Width="73px"></asp:TextBox>
                                </ItemTemplate>
                                <FooterTemplate>
                                
                                 <span style="font-size: 14pt; color: maroon">
                                    Total</span><br />
                                    <asp:Label ID="E" CssClass="myclass1" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>
                                    <br />
                                    <asp:HiddenField ID="hiddenTotal1" runat="server" />
                                    <asp:TextBox ID="RN" runat="server" Width="87px" Visible="false"></asp:TextBox>
                                
                                </FooterTemplate>
                                <FooterStyle VerticalAlign="Bottom" />
                                <HeaderStyle Width="40px" ForeColor="Green" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            
                             
                             <asp:TemplateField HeaderText="Skin Condition">
                                <ItemTemplate>
                                    <asp:DropDownList ID="D1" runat="server" AppendDataBoundItems="True" DataSourceID="SC"
                                        DataTextField="SkinConditionName" DataValueField="SkinConditionName"
                                        TabIndex="6">
                                        <asp:ListItem Text="Select"></asp:ListItem>
                                    </asp:DropDownList><asp:SqlDataSource ID="SC" runat="server" ConnectionString="<%$ ConnectionStrings:CHEMIMSConnectionString %>"
                                        SelectCommand="SELECT SkinConditionName FROM SkinCondition WHERE (SkinConditionName <> 'Raw')"></asp:SqlDataSource>
                                         </ItemTemplate>
                                 <HeaderStyle ForeColor="Green" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="Rejection Pieces">
                             
                                <ItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" TabIndex="7" Width="73px"></asp:TextBox>
                                </ItemTemplate>
                                <FooterTemplate>
                                 <asp:Button ID="z" runat="server" AccessKey="A" BackColor="Transparent" BorderColor="Transparent"
                                        BorderStyle="Dashed" BorderWidth="1px" Font-Bold="True" Font-Names="Palatino Linotype"
                                        Font-Size="10pt" ForeColor="#FFFFFF" Height="39px" OnClick="z_Click" Style="background-image: url(images/btn_5.png)"
                                        TabIndex="11" Text="Add Item" Width="95px" />
                                    <br />
                                
                                 <span style="font-size: 14pt; color: maroon">
                                    Total</span><br />
                                    <asp:Label ID="EF" CssClass="myclass1" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>
                                    <br />
                                    <asp:HiddenField ID="hiddenTotal12" runat="server" />
                                   
                                  
                                </FooterTemplate>
                                <FooterStyle VerticalAlign="Bottom" />
                                <HeaderStyle Width="40px" ForeColor="Green" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="Remarks">
                             
                                <ItemTemplate>
                                    <asp:TextBox ID="RTextBox" runat="server" TabIndex="7" Width="262px"></asp:TextBox>
                                </ItemTemplate>
                                 <HeaderStyle ForeColor="Green" />
                                 
                                 
                              
                               
                            </asp:TemplateField>
                            
                            
                            
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" runat="server" Font-Italic="False" Font-Names="Palatino Linotype"
                                        Font-Size="11pt" Font-Underline="True" ForeColor="#000000" OnClick="LinkButton1_Click">Remove</asp:LinkButton>
                                </ItemTemplate>
                                <HeaderStyle Width="10px" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        &nbsp;
        <asp:TextBox ID="TextBox7" runat="server" onblur="if(this.value == '')this.value='0';"   Font-Bold="False" ForeColor="Black"
            Style="z-index: 120; left: 405px; position: absolute; top: 85px" TabIndex="1"
            Width="18px" BackColor="#99FFFF" Visible="False"></asp:TextBox>
        <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="TextBox1"
            ControlToValidate="TextBox7" Display="Dynamic" ErrorMessage="Your Arrived Pieces  Is Not Equal To Checked Pieces"
            Font-Names="Palatino Linotype" Style="z-index: 121; left: 357px; position: absolute;
            top: 19px" Type="Integer" ValidationGroup="aa">*</asp:CompareValidator>
        <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Palatino Linotype"
            Font-Size="12pt" ForeColor="#000033" Height="22px" Style="z-index: 122; left: 124px;
            position: absolute; top: 70px">Enter Date</asp:Label>
        <asp:TextBox ID="TextBox8" runat="server" onkeyup="return CopyText();" Style="
            left: 209px; position: absolute; top: 71px; z-index: 123;" TabIndex="1" Width="92px"></asp:TextBox>
        <asp:Label ID="Label5" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="Palatino Linotype"
            Font-Size="14pt" ForeColor="Maroon" Height="26px" Style="z-index: 124; left: 705px;
            position: absolute; top: -7px" Text="Lot Details" Visible="False"></asp:Label>
        <cc1:calendarextender id="CalendarExtender1" runat="server" format="dd-MMM-yyyy"
            popupbuttonid="Image1" targetcontrolid="TextBox8"></cc1:calendarextender>
        <asp:ImageButton ID="Image1" runat="server" ImageUrl="~/cal.png" onkeydown="return (event.keyCode!=13)"
            Style="z-index: 125; left: 310px; position: absolute; top: 65px" TabIndex="89" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox8"
            ErrorMessage="Please Enter Date " Font-Bold="True" Font-Names="@Meiryo" Font-Size="10pt"
            SetFocusOnError="True" Style="z-index: 126; left: 343px; position: absolute;
            top: 74px" ValidationGroup="aa">*</asp:RequiredFieldValidator>
        &nbsp; &nbsp;
        <asp:Panel ID="Panel1" runat="server" Height="255px" ScrollBars="Vertical" Style="z-index: 127;
            left: 661px; position: absolute; top: 21px" Width="209px" Visible="False">
            &nbsp;
        </asp:Panel>
        <asp:Label ID="Label7" runat="server" Font-Bold="True" Font-Italic="False" Font-Names="Palatino Linotype"
            Font-Size="14pt" ForeColor="#000033" Height="26px" Style="z-index: 128; left: 78px;
            position: absolute; top: -70px" Visible="False"></asp:Label>
        &nbsp; &nbsp;&nbsp;
    </div>
  
</asp:Content>

Hi..

Anybody here to help me in this…

Thanks

Priya_here

<asp:Label ID="E" CssClass="myclass1" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

 <asp:Label ID="F" CssClass="myclass2" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

 <asp:Label ID="Label8" runat="server"></asp:Label>

What i need here is

my Label8!=class1+myclass2 how would be my script…?

Hi,

Your question is not clear. You have not explained what you want? Do you wnat to concanate two string and show in the third label. Or you want to add two number and show in the third label.

For concatanation you try-

$("span[id*=Label8]").html($(".myclass1").html()+" "+$(".myclass2").html());

And for addition you can try-

$("span[id*=Label8]").html(parseFloat($(".myclass1").html())+parseFloat($(".myclass2").html()))

hi..

I have my labe8 in my aspx let us consider my label8 has value 50

now my footer template myclass1 has 20 and myclass2 has 25 now i need to shopw alert please check value 

if its equal then no alert message.. this what i need now

then 

<FooterTemplate>
<asp:Label ID="E" CssClass="myclass1" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

<asp:Label ID="F" CssClass="myclass2" runat="server" Font-Size="16pt" ForeColor="Teal"></asp:Label>

</FooterTemplate>

[RESOLVED]visibility hidden

Hi, I have a CompareValidator on my page. I want to use JQuery to see if it is shown or not. For some reason. when it is not shown, the JQuery is returning that it is shown. Why is this? And how can I check if the CompareValidator is visible or not? I notice
that the code for the CompareValidator looks like this:

<span id="content_1_compare" style="color:red; visibility: hidden;">

Does this have something to do with visibility:hidden?

Here is my JQuery that checks if something is visible or not (works when I check for visibility of required field validators)

$("#content_1_compare").is(":visible")

Thanks in advance

Try reading the .css() for the "visibility" attribute and checking if it’s hidden. 

[RESOLVED]Weird designer behavior with update panel on form

I just added an update panel to my page, and now it displays as if half the controls (those below and outside the update panel) are outside the page body. They aren’t (the purplish does go around them and I can select them) outside the content portion of
the page, but for some reason it doesn’t extend the entire content area down, only enough to allow me to select and edit the controls. It makes adding new controls, etc very tough. If I remove the update panel, then everything is fine and the white content
area extends down all the way.

Any ideas?

VS Designer

Post your markup. 

Sorry, should have included that!
Master page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="CotC.master.cs" Inherits="CotCWeb.CotC" %>


<!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>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Content page:

<%@ Page Title="" Language="C#" MasterPageFile="~/CotC.Master" AutoEventWireup="true" CodeBehind="register.aspx.cs" Inherits="CotCWeb.register" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">  
    Your email address<br />
    <asp:TextBox ID="txtEmailAddress" runat="server" Width="255px"></asp:TextBox>        
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
        ControlToValidate="txtEmailAddress" ErrorMessage="*"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="valEmail" runat="server" 
        ControlToValidate="txtEmailAddress" 
        ErrorMessage="Please enter a valid email address."></asp:RegularExpressionValidator>
<br />Please enter a password for your account<br />
<asp:TextBox ID="txtPass01" runat="server" TextMode="Password"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
        ControlToValidate="txtPass01" ErrorMessage="*"></asp:RequiredFieldValidator>
        
<asp:TextBox ID="txtPass02" runat="server" TextMode="Password"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" 
        ControlToValidate="txtPass02" ErrorMessage="*"></asp:RequiredFieldValidator>
    <asp:CompareValidator ID="valPassword" runat="server" 
        ControlToCompare="txtPass01" ControlToValidate="txtPass02" 
        ErrorMessage="The passwords you entered do not match."></asp:CompareValidator>
<br />
Please enter your first name and surname<br />
<asp:TextBox ID="txtFirstname" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
        ControlToValidate="txtFirstname" ErrorMessage="*"></asp:RequiredFieldValidator>
   
<asp:TextBox ID="txtSurname" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
        ControlToValidate="txtSurname" ErrorMessage="*"></asp:RequiredFieldValidator>
    <br />
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" 
        ChildrenAsTriggers="False">
        <ContentTemplate>
            City<br />
            <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                ControlToValidate="txtCity" ErrorMessage="*"></asp:RequiredFieldValidator>
            <br />
            <br />
            Country<br />
            <asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" 
                onselectedindexchanged="ddlCountry_SelectedIndexChanged">
            </asp:DropDownList>
            <br />
            <br />
            State/Region/Province<br />
            <asp:DropDownList ID="ddlRegion" runat="server">
            </asp:DropDownList>
            <br />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlCountry" 
                EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
<br />
    Your age:<asp:DropDownList ID="ddlAge" runat="server">
</asp:DropDownList>
    <br />
<br />
    How did you hear about CotC?<asp:DropDownList ID="ddlHowHeard" runat="server">
</asp:DropDownList>
<br />
<br />
Please indicate your top three interests at Con on the Cob:<br />
1)<asp:DropDownList ID="ddlInterest01" runat="server">
</asp:DropDownList>
    2)<asp:DropDownList ID="ddlInterest02" runat="server">
</asp:DropDownList>
   3)<asp:DropDownList ID="ddlInterest03" runat="server">
</asp:DropDownList>
    <br />
<br />
Have you attended Con on the Cob before?
<asp:DropDownList ID="ddlReturnVisit" runat="server">
    <asp:ListItem Selected="True">No</asp:ListItem>
    <asp:ListItem>Yes</asp:ListItem>
</asp:DropDownList>
    <br />
    <br />
    <asp:Button ID="butSubmit" runat="server" Text="Button" 
        onclick="butSubmit_Click" />
</asp:Content>

I copied your pages into my vs2010 Professional and did not see a problem.  The design view rendered as it should.  Perhaps it is a version problem with your vs.  Perhaps if you check for updates.

Interesting. I’m using VS 2008 Standard SP1. Maybe I’ll try recreating the page from scratch and seeing if it does it again.

Thanks for trying it out!