Web Forms :: Determine Which Gridview Control Raised Postback?
May 17, 2010
I have 5 infragistics webdatagrid controls on page, I am using paging and sorting features for the grids. For paging to work for a grid, I need to rebind the grid on every postback in Page_Init or Page_Load event and after that page_indexchanged event gets fired.
Now, when I click on any page number in second grid, I don't want data of other 4grids to be re-bind. I just want to know which grid has done postback and bind that particular grid.
I checked out Request.Forms["__eventargument"] but its value is comma (",").
Consider the scenario for asp.net gridviews and depending upon that I'll get idea to proceed with Infragistics controls.
In the last cell of my gridview I have 2 separate linkbuttons. I want to further process them using Gridview Onrowcommand event but How would I know which particular link has actually raised the event.
Anyone know how to determine which ImageButton was clicked in a gridview when there are multiple Imagebuttons in a row. I am guessing it's gotta be done in SelectedIndexChanged.
I have a User Control that has been added to the page dynamically. When I click a button on that user control:
The button_click event is NOT being raised The page posts back The user control is removed from the page
Here's the button-click event on my User Control:
Protected Sub btnAddAttribute_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddAttribute.Click Try Dim attrName As String = txtAddAttributeName.Text Dim attrValue As String = txtAddAttributeValue.Text 'ADD ATTRIBUTE TO ATTRIBUTE TABLE putSQLData("INSERT INTO OD_Attribute_Values (AttributeName, AttributeValue) VALUES('" & attrValue & "', '" & attrName & "'")...........
Is there a way where I can actually view the name of a post back element? Below code goves me an alert but all it says is "object HTMLSelectElement". In my case it should be DropDownList3 based upon a "selectedindexchanged" event with autoppostback=true.
Code: var pbControl = null; pbControl = args.get_postBackElement(); alert(pbControl); var ExecutingControl = "DropDownList3" if (ExecutingControl == pbControl) { alert("DropDownList3 - is the post back element");
I'm implementing a custom page caching solution and I don't want the request to be cached or retrieved from the cache if it's in response to a form submission or some sort of asp.net postback.I'm trying to figure out if the current HttpRequest is a postback. Is there a way of doing this outside the context of a page or other usercontrol? In otherwords if I'm inside an HttpModule I don't have access to this.IsPostBack but I still need to determine if it is in fact a postback.
I'm trying to extend the GridView control to enable sorting and paging for any situation.
When using my control I am fetching data from a database and filling a DataSet with it, then binding the GridView upon every page load. My first question would be, is this the correct approach?
To sort the GridView I am overriding the OnSorting method which stores the sort expression and direction in the ViewState, then creates a DataView and utalises the Sort method to sort the underlying data. It then sets the Data Source to this DataView and rebinds the GridView.
Paging is handled by OnPageIndexChanging which simply sets the PageIndex property and again rebinds the GridView.
My problem is; when any control causes a postback my GridView is no longer sorted, presumably because it is persistently rebound. If I don't rebind it then the GridView is empty on postback since the data isn't automatically stored in the ViewState. I have considered saving the data source in the ViewState but I would assume that this is bad practice for large amounts of data? - also DataViews are not seralisable.
The only solution I can think of currently is to override OnDataBound and sort the data every time. This results in a double sort when paging triggers a postback which seems inefficient. Code illustration of this below,
[Code]....
I'm looking for the cleanest 'best practice' solution as this is a learning exercise more than anything else.
I have a web application which has rather a lot of controls. I also have several buttons (add, edit, save, cancel). Most of my content page is in an update panel so it does not process the whole page. On form submit I have some javascript code which shows a div 50% opacity and an animated gif to prevent users clicking on the buttons more than once whilst it is processing the data to the server. Here is the javascript / call:
Code: onsubmit="overlay();" function overlay() { el = document.getElementById('overlay'); el.style.display = "inline"; document.getElementById('Image2').src = "../Images/loader.gif"; } function removeoverlay() { el = document.getElementById('overlay'); el.style.display = "none"; }
The problem is it the form disables like I want it and the giff animates for about 1.5 seconds but it does not enable the form for a further 4 seconds.
Is there anyway to see what it happpening at this point. If I put some watches in my code behind it runs through less than a second so what else can it be doing.
Also on some laptops the form does not fit vertically so there is a scroll bar. When the div is shown on a submit it does not do the full screen including the scroll area.
I have a asp.net page where we need to dynamically generate a table, table row, and a checkbox controls in this row. A button serves Add Row and create checkbox function, which works fine. We have another button which serves on deleting the selected row if a user checks the checkbox. The deleting event is dynamically added to the checkbox. But the delete button is not working at all. I think that the page does not maintain the states of dynamically generated controls, even I set Page enable view state to True. Here is the code:
I am generating a table dynamically with one row having four cells.
First cell is having checkbox and below is the code how i declare it and assign it a new id at runtime.
I'm developing IP Blacklisting HttpModule in asp .net application and I found one very annoying thing. Each request to the asp net page generates tens of "subrequests" to application resources like images, client side scripts, styles etc.
Now in my application I'm listing to the BeginRequest event and when it is fired I'm loading Dictionary with blacklisted IPs from application cache and check user's IP against it. I've made a simple log of what is actualy happening during each page view, here are the results:
[Code]....
As you see, one request to Login page causes BeginRequest to fire 18 times, there is 18 dictionary loads, 18 lookups etc. That's not the way I want it to be.
Is there any other event that is raised only once per each request? Where do you place the blacklisting mechanism in your applications? I know I can do it through ISAPI filter, but the catch is, this site is on the shared hosting and I'm not sure I can use it on their IIS. Also I'm not sure if ISAPI filter can access some piece of cache with this blacklist (I don't want to load it from DB on each request, that's obvious).
I have a gridview with a template filed which contains an embedded gridview, which may or may not contain any records. I want to be able to make the master gridview row a different color for those rows whose child gridview has records. My plan is to add a sqldatasource to the page that targets the child gridview table and during the master gridview RowDataBound event I would check to see if there are any records and apply the formatting accordingly.
I have wired an event to handle delete command for my GridView. But I cannot determine which the record's unique key, in my case stored in DOCIDNO field. All I get is a row index, such as 0, 1, 2 which obviously cannot be used to accurately delete a record from database.
I have an application that I would like to be able to allow the user to modify multiple characteristics of each record within a datagrid.
Most characteristics require data to be entered in a text box but some a check box would be more appropriate.
My question is does a gridview column need to have all the same item template controls? or could I read from the database the control type and dynamically alter the template control for each row as it loads?
I've implemented this string format in my NavigateUrl to pass a dynamic querystring depending on the clicked item!
but you see the first part in the string format where it says "~/PLayer.aspx" i want the user control to automatically change this part according to where it's placed!
Let's say I have a DropDownList server control, called "CategoriesDDL" and the ClientID proeprty determines its client side id, which is its ID prefixed with the id's NamingContainer's ids. In this case the client side ID is CP1_CategoriesDDL. But what is the rule regarding the client side name, in this case "ct100$CP1_CategoriesDDL"?
I've a Gridview control using an ODS(ObjectDataSource) to fetch data. For the best performance and efficiency, I've turned-off the view state of Gridview (i.e. EnableViewstate = "false".And I've also enabled caching in the associated Objectdatasource. This eliminates as much as 50-60% performance optimization because it eliminates the DB round-trip .. courtesy ODS Caching.So, after this I got stuck into the famous "ODS sorting" issue but I managed to invent a tricky solution for it and its working fine
I'm building several user controls (ASCX) for my website and several of them are very similar in what they do. (As a side note, I must create unique UC's even if they're similar because I'm creating widgets for the new Telligent Community themeing system). For example, two of them are different but use the same front-end code to create a 2 or 3 tab panel where you can click a tab and it changes the data below. I have a single JS file to handle these tabs and the animations. I'm currently dynamically adding my JS file reference to the <head> from the user controls' code via:
If I have both of these controls on a page though, both will add this JS file reference. How can I do a check to see if it is already added from another control?
var onBeforeUnloadFired = false; window.onbeforeunload = function (sender, args) { if(window.event){ if(!onBeforeUnloadFired) { onBeforeUnloadFired = true; window.event.returnValue = 'You will lose any unsaved changes!'; //IE } } else { return 'You will lose any unsaved changes!'; //FX } windows.setTimeout("ResetOnBeforeUnloadFired()", 1000); } function ResetOnBeforeUnloadFired() { //Need this variable to prevent IE firing twice. onBeforeUnloadFired = false; }
I'm trying to achieve an edit screen where the user is warned before navigating away. It works fine except I get the pop up for normal post backs of button clicks. I'm hoping to avoid this so I'm figuring if I could determine which button was pressed it would work. Does anybody know how to determine which button was pressed in the indows.onbeforeunload? Alternatively anyone know a better approach to what I'm trying to achieve?