Any suggestions?

Results 1 to 2 of 2

Thread: Any suggestions?

  1. #1
    Join Date
    Dec 1969

    Default Any suggestions?

    Hi I have a datagrid. Within this datagrid, I have a two textboxes. What I want to do is check if the textbox2 value is greater than value of textbox1. If it is then prompt the user. <BR><BR>To achieve the above I have written a server side validation module. It works fine. But to use the server side validation I have to set the autopostback property of the textbox2 to true. And that causes all kinds of problems, the page does not get post back properly etc. etc. <BR><BR>So my second line of attack to this problem is a client side script. I have written a small validation check in js (please see below) <BR><BR>Dim scriptString As String = "&#060;script language=JavaScript&#062; function DoClick() {" <BR> scriptString += "if(parseInt( document.getElementById(""item_received"").value) &#062; parseInt( document.getElementById(""item_received2"").value) )" <BR> scriptString += "{ alert(&#039;Text box 1 is higher than textbox 2&#039;); } } " <BR> scriptString += "&#060;" <BR> scriptString += "/" <BR> scriptString += "script&#062;" <BR><BR> If (Not IsClientScriptBlockRegistered("clientScript")) Then <BR> RegisterClientScriptBlock("clientScript", scriptString) <BR> End If <BR><BR>But now my question is how can I refer this from my datagrid itemtemplate? <BR><BR>Here is my textbox ... <BR><BR>&#060;asp:TextBox id="item_received" Text="0" width="19px" cssclass="basic" Runat="server"&#062;&#060;/asp:TextBox&#062; <BR> &#060;/ItemTemplate&#062;

  2. #2

    Default RE: Any suggestions?

    Is this the other thread continued or do you have more problems.<BR><BR>First thing is to fix your postback problems, as they will lead to more problems.<BR><BR>You should have a simple, if inelegant, solution if your postbacks work as they should.<BR><BR>If your textboxes are repeated, you have to manage all the ClientID/UniqueID.<BR><BR>In the item_databound, you can emit javascript for each pair. <BR><BR>function doClientSide_Item1()<BR>{<BR> DoClick("&#060;UniqueIDOfFirstOfPair&#062;","&#060 ;UniqueIDofSecondOfPair&#062;");<BR>}<BR>and in the onchange or onblur of each textbox in the pair, you call doClientSide_Item1()<BR><BR>You will have doClientSide_Item1,doClientSide_Item2 and so on for each.<BR><BR><BR>You can also explore using html input type=text so that when you access it in javascript you hava an array of controls.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts