Reputation: 11010
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?
Upvotes: 2
Views: 4340
Reputation: 68440
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);
}
Upvotes: 5
Reputation: 18316
I think you're missing document.getElementById.
So something like:
document.getElementById('<%=txtATrendStartDate.ClientID%>').value
Upvotes: 0
Reputation: 6184
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;
Upvotes: 0