0

I want to pass three textbox values to a javascript function. However its not working.Any help is really appreciated.This is what I have tried.

<asp:ImageButton ID="ibut_cheque2" runat="server" target="_blank"
OnClientClick='<%# string.Format("window.open(\"Product.aspx?pid=\" +
document.getElementById(\"{0}\").value & chdate=\" + 
document.getElementById(\"{1}\").value & pname=\" + 
document.getElementById(\"{2}\").value, 
null,\"scrollbars=yes,top=10,left=10\", \"true\");", 
Form.FindControl("txt_voucher").ClientID,
Form.FindControl("txtbox_chqdate").ClientID,
Form.FindControl("txtbox_chprovider").ClientID)%>'
AlternateText="Print" CssClass="btn5" ForeColor="White" ToolTip="Print Cheque" />
4
  • Can you tell what you actually want to do in detail Commented Nov 16, 2017 at 4:44
  • Actually I need to pass these 3 textbox values to another page.And capture these values into a variable in the other page. Commented Nov 16, 2017 at 5:08
  • instead of using javascript function you can use Session to store value from one page and retrive those value in another page like this:stackoverflow.com/questions/47277535/… Commented Nov 16, 2017 at 6:31
  • There are a few ways to do this better ... Could be via SessionState or PreviousPage property ... And in my opinion you'd better do this in .cs and not in .aspx Commented Nov 17, 2017 at 12:02

2 Answers 2

1

On first Page Button click code

<script>
var value1="value1";
var value2="value2";
var queryString = "?para1=" + value1 + "&para2=" + value2;
window.location.href = "page2.html" + queryString;
</script> 

On Second Page

<script>

var queryString = decodeURIComponent(window.location.search);
queryString = queryString.substring(1);
var queries = queryString.split("&");
for (var i = 0; i < queries.length; i++)
{
  document.write(queries[i] + "<br>");
}

</script> 

Hope this will help you

Sign up to request clarification or add additional context in comments.

Comments

0
     <asp:Button ID="PrintCheck" runat="server" target="_blank" 
     OnClientClick='openWindow()'   Text="Print Cheque" CssClass="btn5" 
     ForeColor="White" Width="120px" ToolTip="Print Cheque" />

     <script type="text/javascript">
     function openWindow() {
     var payname = document.getElementById('<%=txtbox_chprovider.ClientID 
      %>').value;
      var chdate = document.getElementById('<%=txtbox_chqdate.ClientID 
      %>').value;
      var chamount = document.getElementById('<%=txt_chamount.ClientID 
      %>').value;
    window.open("Product.aspx?payname=" + payname + "&chdate= " + chdate + " 
    &chamount= " + chamount + "", "_blank", 
    "toolbar=yes,scrollbars=yes,top=10,left=10", "true");
          };
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.