Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way I can do onchange at behind code VB.Net like how it works on asp.net and javascript? I wanted to automatically show DataGridview right after date is selected.

What I have tried:

I have this ASP.Net code for Date From to Date To :
ASP.NET
<asp:TextBox runat="server" ID="dateFrom">
  To  
<asp:TextBox runat="server" ID="dateTo">

Javascript for Date From and Date To :
JavaScript
$(document).ready(function () {
    $("[id$=dateFrom]").datepicker({
        showOn: 'button',
        buttonImageOnly: true,
        buttonImage: 'source/calendar-icons-2.png'
    });
});

$(document).ready(function () {
    $("[id$=dateTo]").datepicker({
        showOn: 'button',
        buttonImageOnly: true,
        buttonImage: 'source/calendar-icons-2.png'
    });
});

Above code is to select Date without autopostback. I want after Date To is selected DataGridview will be shown. Is there any way I can do it without javascript? Thank you.
Posted
Updated 8-Nov-16 16:28pm

1 solution

I got a way on how to do it. I am adding AutoPostBack="true" on the Date To coding which is
ASP.NET
<asp:textbox runat="server" id="dateTo" autopostback="true">

So I am adding these at code behind:
VB
If IsPostBack Then
	If dateFrom.Text <> "" AndAlso dateTo.Text <> "" Then
		'Some stament goes here
	End If
End If
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900