2

How to pass two textbox values to a javascript function on a button click event.I have tried it like this but it is not working.here is my code

<asp:LinkButton ID="lnkBTNSubmit" runat="server" CssClass="buttonlink"
  OnClientClick="checkDateRange(GetTextBoxValue('<%= txtATrendStartDate.ClientID %>'.value),GetTextBoxValue('<%= txtATrendEndDate.ClientID %>'.value))">Submit</asp:LinkButton>

and

function checkDateRange(start, end)
{
}

Any Suggestion?

0

3 Answers 3

5

Something like this would do the trick

<asp:LinkButton ID="lnkBTNSubmit" runat="server" CssClass="buttonlink"
  OnClientClick="return onBtnSubmitClick()">Submit</asp:LinkButton>

function onBtnSubmitClick(){
   var start = document.getElementById('<%= txtATrendStartDate.ClientID %>').value;
   var end = document.getElementById('<%= txtATrendEndDate.ClientID %>').value;
   return checkDateRange(start, end);
}
Sign up to request clarification or add additional context in comments.

Comments

0

do it in your inline/header javascript like this:

var element = document.getElementById('<%= txtATrendEndDate.ClientID %>');

element.value

and if you set ClientIDMode="Static" you can do:

var value= document.getElementById('txtATrendEndDate').value;

Comments

0

I think you're missing document.getElementById.

So something like:

document.getElementById('<%=txtATrendStartDate.ClientID%>').value

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.