<asp:UpdatePanel runat="server" ID="adavanceGrpngLB_UP" UpdateMode="Conditional">
<ContentTemplate>
<%--code[@**] 10-Nov-22 code changed Adding Search text box in Target Column Mapping Setting Popup code start--%>
<asp:TextBox ID="search_advgrp" class="form-control form-control-sm mt-1 mr-1 adv_search_col" runat="server" AutoPostBack="false" OnTextChanged="searchFilterTextAdvancedgrp" placeholder="Search Column"></asp:TextBox>
<asp:Button ID="clearListBoxAdvGrp" OnClick="clearSearchTextAdvancedgrp" title="Clear Search" runat="server" Text="x" class="Adv_clr_ser"></asp:Button>
<%--code[@**]10-Nov-22 code changed Adding Search text box in Target Column Mapping Setting Popup code end --%>
<asp:Button runat="server" ID="loadcol" OnClick="Load_advancegroupLB" Style="display: none" />
<asp:ListBox runat="server" ID="adavanceGrpngLB" SelectionMode="Multiple" AutoPostBack="false" Style="max-width: 25em; min-width: 13em; margin-left: 2em; margin-right: .5em; max-height: 60em;"></asp:ListBox>
<asp:Button runat="server" ID="Button3" OnClick="advancegroup_additem_Click" Style="position: absolute; margin-top: 1.1em;" Text=">>" />
<asp:Button runat="server" ID="Button4" OnClick="advancegroup_removeitem_Click" Style="position: absolute; margin-top: 3.2em;" Text="<<" />
<asp:ListBox runat="server" ID="ExadavanceGrpngLB" SelectionMode="Multiple" AutoPostBack="false" Style="max-width: 25em; min-width: 13em; width: 13em; margin-left: 3.1em; max-height: 60em;"></asp:ListBox>
<span>
<%-- <button type="button" id="Button5" runat="server" title="Rename this Rule." style="height: 2.2em !important" class="ml-1 fa fa-angle-double-up" ><i class="fas fa-edit"></i></button>
<button type="button" id="Button6" title="Delete this Rule." style="heighty: 2.2em !important" class="ml-1 mr-1 btn btn-sm btn-outline-secondary" ><i class="fas fa-trash-alt"></i></button>--%>
<%-- <asp:Button runat="server" class="ml-1 fa fa-angle-double-up rotate" ID="group_up" OnClick ="advancegroup_moveup_Click" Text="<<" Style="position: absolute; margin-top: 1.1em;"/>
<asp:Button runat="server" class=" ml-1 fa fa-angle-double-down rotate" ID="group_down" OnClick ="advancegroup_movedown_Click" Text=">>" Style="position: absolute; margin-top: 3.2em;"/>--%>
<%--02 July22 code[@*] Button--%>
<asp:Button runat="server" class="ml-1 fa fa-angle-double-up rotate" ID="group_up" OnClick="advancegroup_moveup_Click" Text="▲" Style="position: absolute; margin-top: 1.1em;" />
<asp:Button runat="server" class=" ml-1 fa fa-angle-double-down rotate" ID="group_down" OnClick="advancegroup_movedown_Click" Text="▼" Style="position: absolute; margin-top: 3.2em;" />
</span>
</ContentTemplate>
</asp:UpdatePanel>
</div>**strong text**
Actually, I am working in the asp.net webform framework. My scenario is if I enter a word in the text box it won't trigger "searchFilterTextAdvancedgrp" which is in the OnTextChange Event. if I change AutoPostBack = true, it triggers that function but Page_Load is also triggered which causes user performance bad. I want to trigger OnTextChange without triggering the Page_Load function. I am new to the development environment if I made any mistake please correct me. thanks in advance. The following code block is my OnTextChange event code block in c#
public void searchFilterTextAdvancedgrp(object sender, EventArgs e)
{
string searchvalueadvgrp = (search_advgrp.Text).Trim(); //length > 0 --->clearSearchTextAdvancedgrp(null, null)
string[] advgrplistBoxItems = new string[adavanceGrpngLB.Items.Count];
WriteLog("***Advanced column length " + adavanceGrpngLB.Items.Count);
WriteLog("Advanced column values" + adavanceGrpngLB.ToString());
WriteLog(" **********List Items *********" + advgrplistBoxItems.ToString());
//081123 code[****] - start get target side columns, assign to advancegrouparraylist
for(int i =0; i< adavanceGrpngLB.Items.Count; i++)
{
advancedGroupingArrayList.Add(adavanceGrpngLB.Items[i].ToString());
}
//081123 code[****] - end get target side columns, assign to advancegrouparraylist
//code[@**] 16-Nov-22 code changed clear the textbox value code start
if (search_advgrp.Text.Length <= 0)
{
clearSearchTextAdvancedgrp(null, null);
return;
}
//code[@**] 16-Nov-22 code changed clear the textbox value code end
List<string> searchListAdv = new List<string>();
WriteLog("Target Array List " + advancedGroupItems.ToString());
// 081222 code[**] Ne need to Loop the Data Array List --
foreach (var item in advancedGroupingArrayList)
{
WriteLog("Values " + item.ToString());
if (item.ToString().ToLower().Contains(searchvalueadvgrp.ToLower())) searchListAdv.Add(item.ToString());
}
// --
//advancedGroupingArrayList
searchListAdv.Sort();
foreach (var eachItems in searchListAdv)
{
WriteLog("each items values adv " + eachItems.ToString());
adavanceGrpngLB.Items.Add(eachItems.ToString());
}
// Sort the ArrayList Directly --
//advancedGroupingArrayList.Sort();
adavanceGrpngLB.DataSource = searchListAdv;
adavanceGrpngLB.DataBind();
//--
// Set the Tooltip After Search
settooltipLB();//--
// 081222 end---
hidejson.Update();
WriteLog("===========" + searchListAdv.ToString());
adavanceGrpngLB_UP.Update();
}
Keep in mind that using an update panel does NOT prevent or mean that the page load event does not trigger (it will). Keep in mind that full regular page lifecycle occurs when using update panels.
The correct term here is what we call a partial page post-back. This STILL means that page load event, and the whole page life cycle STILL runs when any post-back occurs in the update panel. It might not look like a page post-back is occurring, but they ARE occurring!!!
Of course, when using an update panel, then ONLY the controls inside of the update panel area can be updated by code behind. And the idea here is that you can reduce the size of the page post-back, since ONLY that part of the page is sent up to the server, and then returned to the client side.
So, while such post-backs with an update panel ONLY posts back part of the web page, the standard page events (such as page load event) will and does run each time.
However, the page load event ALWAYS did run each time say for a simple button click. This means that setup code, data loading code, and general code that you run to setup the web page?
I can and often should be placed in the page load event, but you need to test if the page is REALLY the first page load.
Thus, 99%, or in fact the last 200 web pages I have built in asp.net webforms?
EVERY ONE has this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadGrid
End If
End Sub
Sub LoadGrid()
GVHotels.DataSource = MyRst("SELECT * FROM tblHotelsA
ORDER BY HotelName")
GVHotels.DataBind()
End Sub
So, note how we write the page load code event to ONLY run one time, and only on the first real page load. As a general rule, you can't re-load the grid, or even a simple combo box, since if you re-load such data each time, then the user’s choices for those controls will be lost.
Remember, for any button click, or auto post back on ANY control, the page load event fires first and THEN the control events code stub fires.
As a result, it is near impossible to build a working web page without having that all important If Not IsPostBack code stub in the page load event.
This advice applies regardless if you using an update panel or not.
However, as above shows, an update panel on post-back will trigger page load first, and THEN trigger your code stub for the auto post back. Stands to reason then when building a page, your page load event code in near all cases needs to be placed inside of that If Not IsPostBack stub, and this applies to near every page you build - not just ones with update panels.
So, keep in mind that a update panel does not prevent post-backs, but ONLY gives the appearance of no post-back occurring (but, behind the scenes, update panels will and do post-back to the server just like a regular full page post-back).
The only difference here is that only "part of" the page is posted to the server). However, this so called "partial" page post back still runs the full complete life cycle of the web page events, including that of page load event (and the other events) for that page each time.
So, now having stated all of the above?
Can you have/use a auto-post back and trigger a page post-back for each key press in the text box?
Well, yes, you can, but that's not going to work all that great, since as noted, you STILL then forcing a page post-back with each key pressed.
This is one case that what you ask for is "possbile", but not all that great of a idea. As I stated, each keypress thus will trigger the forms life cycle, and page load will trigger, and THEN your code behind stub for the on-changed event.
Now, to be honest, in the past have I done above? Well, yes, I did since I did not really have the knowledge and skills to write client side JavaScript. And often we do resort to a update panel, since that is a way to "avoid" having to write client side JavaScript for updating part of a web page. And in most cases, the update panel does and can come to the rescue. In other words, a update panel is a stroke of genius for webforms.
However, update panels do have their limits, and one such case is trigging that partial page post-back for each given keystroke. It not all that great of a idea here, since each key press is going to trigger that page lifecycle which involves a rather heavy page post back (partial) and you will endure a whole round trip to the server.
This page post-back will run REALLY good on your developer box, since the web server, the web browser, and server side code are all running on the SAME computer.
This can give you the illusion of great speed. However, at deployment time, you find that post back from a REAL client desktop, over the internet, and thus enduring that "round trip" to the server is going to run MUCH MUCH slower then what you experiencing now on your developer box.
In effect, the bandwidth from browser to server is not really limited during development, but it WILL be at deployment time. As a result, suffering or adopting a WHOLE page post-back (or a partial post-back is going to stress the system too much for each keystroke.
I suggest you drop the user of the update panel, and use a client side on-change event for the text box, and call a web method. While the update panel "spoils" you, and you in most cases don't have to write that client side JavaScript + web method? Your case is one such case due to the keystroke processing you wish in real-time.