I have a Panel on my vb.net web page. I used javascript to show and hide the panel. And there is one text box and Gridview within that panel. I want to load the grid on text change event of this text box. When this event fired, the Panel get closed. how
can I prevent the panel close? AutoPostBack property of that textbox is true. I have given my code
Protected Sub txtSearch_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
can I ask you one more doubt...... I have a text box in my web page. And I need to load gridview on textbox changing event. I tried TextboxChanged event. But this event occurs after the textbox property changed. I need my textbox to raise the event when
typing into that text box.
Yes, its the default behavior of textchanged event in web pages. Because unlike windows forms, event invoking on every character entered is annoying for the user. So i suggest to keep it like this.
But still, if u want it to work, then u need to write javascript for this :
Can I ask one more doubt?? Can I do with out refreshing the page?? Because it is taking long time to load gridview to load again. Is there any javascript function to call CodeBehind GridviewBind Method??
If u do it without refreshing your page, how the grid will show new values? It will not..
For making it performance effective:
1. Use ajax UpdatePanel.
2. Use webservice to grab your data asynchronously and keep binding it to the grid as the text is kept entering in textbox. Search about it and you will find good examples
itsjp
Member
24 Points
103 Posts
Panel Closing on textbox text chnaged
Sep 19, 2012 05:13 AM|LINK
I have a Panel on my vb.net web page. I used javascript to show and hide the panel. And there is one text box and Gridview within that panel. I want to load the grid on text change event of this text box. When this event fired, the Panel get closed. how can I prevent the panel close? AutoPostBack property of that textbox is true. I have given my code
Protected Sub txtSearch_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
If (txtSearch.Text.Trim() = "") Then
Else
gvList.DataSource = ObjDataHandler.getByName(txtSearch.Text.Trim() + "%%")
gvList.DataBind()
End If
End Sub
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Panel Closing on textbox text chnaged
Sep 19, 2012 06:16 AM|LINK
In the above code, in the else part, set your panel's visible property to true also.
Because, you only set it as visible on the client-side, so when the page is loaded again, the panel will get its properties from server side.
So u should set the visible = true to server side too
--
Hope this helps..
Mark as Answer, if it answers you..
--
itsjp
Member
24 Points
103 Posts
Re: Panel Closing on textbox text chnaged
Sep 19, 2012 07:21 AM|LINK
thanks mate.. thanks a lot......
can I ask you one more doubt...... I have a text box in my web page. And I need to load gridview on textbox changing event. I tried TextboxChanged event. But this event occurs after the textbox property changed. I need my textbox to raise the event when typing into that text box.
Can you please help me??
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Panel Closing on textbox text chnaged
Sep 19, 2012 07:41 AM|LINK
Yes, its the default behavior of textchanged event in web pages. Because unlike windows forms, event invoking on every character entered is annoying for the user. So i suggest to keep it like this.
But still, if u want it to work, then u need to write javascript for this :
<script type="text/javascript"> function DoProcess(txtbx) { alert(document.getElementById(txtbx.id).value); return false; } </script> <asp:TextBox ID="TextBox1" runat="server" onkeyup="DoProcess(this);" ></asp:TextBox>--
Hope this helps..
Mark as Answer, if it answers you..
--
itsjp
Member
24 Points
103 Posts
Re: Panel Closing on textbox text chnaged
Sep 19, 2012 08:48 PM|LINK
But how can I bind my Gridview for every KeyUp event using javascript?? How can I call a Code Behind Method from Client Side function??
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Panel Closing on textbox text chnaged
Sep 20, 2012 02:07 AM|LINK
The eaisier way is to ;
1. Keep a hidden button on your page, find it in JS method and call its click. It will postback it to server.
2. On the server, handle its click method.
3. In that method, do whatever you want to do (Bind the gird in your case)
like this;
<script type="text/javascript"> function DoProcess(txtbx) { alert(document.getElementById(txtbx.id).value); document.getElementById('<%= btnHidden.ClientID %>').click(); return false; } </script> <asp:TextBox ID="TextBox1" runat="server" onkeyup="DoProcess(this);" ></asp:TextBox> <asp:Button ID="btnHidden" runat="server" Text="Hidden Button" style="display:none" onclick="Button3_Click" /> // code-behind (server side) protected void Button3_Click(object sender, EventArgs e) { // Use the value of TextBox1.Text; // Bind your grid here }--
Hope this helps..
Mark as Answer, if it answers you..
--
itsjp
Member
24 Points
103 Posts
Re: Panel Closing on textbox text chnaged
Sep 20, 2012 02:41 AM|LINK
Can I ask one more doubt?? Can I do with out refreshing the page?? Because it is taking long time to load gridview to load again. Is there any javascript function to call CodeBehind GridviewBind Method??
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Panel Closing on textbox text chnaged
Sep 20, 2012 02:45 AM|LINK
If u do it without refreshing your page, how the grid will show new values? It will not..
For making it performance effective:
1. Use ajax UpdatePanel.
2. Use webservice to grab your data asynchronously and keep binding it to the grid as the text is kept entering in textbox. Search about it and you will find good examples
--
Hope this helps..
Mark as Answer, if it answers you..
--
itsjp
Member
24 Points
103 Posts
Re: Panel Closing on textbox text chnaged
Sep 20, 2012 03:21 AM|LINK
Sorry mate..... I didn't get you actually........
Can I get any example link please
hassanmehmoo...
Star
8970 Points
1590 Posts
Re: Panel Closing on textbox text chnaged
Sep 20, 2012 03:24 AM|LINK
See this :
http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
--
Hope this helps..
Mark as Answer, if it answers you..
--