Using Ajax method (how to do it) - c#

Using an update panel in ASP.NET and with the help of a good tutorial on ListView from Matt Berseth I accomplished the image below.
alt text http://www.balexandre.com/temp/StackOverflow_HowToStartUsingAJAX.png
The behavior is, when I click the BOLD names, the rows below that name with numbers are collapsed.
Getting the DATA:
This is a SDK WebService that I cannot change, and with it I get the bold names in one call and for each bold name the list of the numerable rows, in this example I had to call 4 times the Web Service
1 call to provide me with all bold names and then 1 call per bold name to get the secondary list.
My employer told me to not do this, but only get the secondary row when a user clicks in the bold name ...
What should I do now? I'm kind'a lost here. :(
I know "what to do" but not "how to do"
I created a new row in the HTML to be replaced using jQuery
in the listView_ItemDataBound method I change the javascript to have that Row ID in order to be easier to use the javascript function
But, how do I show a "loading" image in that particular Row and load the secondary list?
(I already have a big one that is used to show a wait message when retrieving the bold names list)
alt text http://www.balexandre.com/temp/SuperOffice_forum_loadingIndicator.png
Do I need to create a middle WebService of my own to request this data right?
BIG problem is that I need to check "On Submit" those checkboxes in the secondary rows as well :(
I'm completely lost here, can anyone show me the light please?

ASP.NET Ajax can can use UpdateProgress the to display an image or anything.
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updPanel1" DisplayAfter="0">
<ProgressTemplate>
<img alt="Please Wait" src="Images/processing.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
You can use javascript to move it to any area on a page by setting the position to absolute.
The best way to do this solution is to program the who page using post backs. Then put an Ajax UpdatePanel on the page.
The web services you can call on the click event on each of the row to populate the data. Put the data in a panel that is hidden. Use Jquery and a start up script to display it if want it to "slide" down.
The best advice I can give is don't worry yet about having a real slick UI. Get the page working, and get the data from the web service. Then after you have that done, work on getting the UI to look better.
This is like playing music, you can't write all the parts of a song at once. You start with a theme then you create the melody, the second and 3rd parts etc. . . .

Related

JQGrid and asp.net

In the past when I've used jqgrid all i have done is had a static web service and the grid loads as the page does. Now I need to have a form that i want to send values from to the service, and the results need to be in the grid.
I'm struggling with a couple of things -
How do i format the url function in the grid to send parameters with it, in the past i have got away with just url: 'JsonData.asmx/GetData
How do i actually call the update method of the grid from a button?
I'm writing the web app in c#, dotnet 4
Thanks
Luke
I see no problem in what you explain. If you could fill the grid data using url: 'JsonData.asmx/GetData' it should continue to work inside of the form. You should only verify the font size which you use in the form to have good look together with the grid.
If you need reload data in the grid you can use $("#grid_id").trigger('reloadGrid',[{page:1}]); (see here).
One other possible problem which you could have: one should create jqGrid once. If you for example need create the form once which contain one grid and later change the for contain to have another grid you could have to use GridUnload method. See here and the demo and here.

asp.net textbox to html page data

Hi I'm a bit rusty with this again, I have a user profile web page and I'm working on making a wall posting system, I can do it the crappy n easiest way: textbox to listbox and then save the listbox as a text document for retrieval when the client logs in again.
But id like to write it to the HTML code or something of that nature. Like those div containers so my style sheet is applied to the data being posted.
Could anyone give me a head start to this?
You know from where you need to copy (sorry... take inspiration) your functionality.
Have a text box
User submits the data...
Add it to DB and either return the same data and add new table row below the previous one
or just on client add extra "TR" below the previous "TR".
It will require jQuery or any other similar thing. You have SO, dissect it using Firebug and build your own version of it.
You can do this with jQuery
$('button').click(function(){
var x = $('textarea').val();
$('div').html(x);
});
Check working example at http://jsfiddle.net/dzert/

Ways to detect changed account/no account found in ASP.NET/C#

I have an ASP.NET page where at the top of the page is a search box. There are 2 text boxes - one is an autocomplete extender for the Name on a database, and one is just inputting the ID.
The page features DetailsViews and GridViews primarily, and even when no account has been searched for, these display blank data which is not ideal. I sort of fixed this by using if (IsPostBack), encasing the elements in a placeholder and setting it to visible only if the page ispostback. But this doesn't cover if the user types in an incorrect ID.
Also, some accounts have huge amounts of data inside the GridView's. I had an issue where because I have no way of detecting when a data source's rows has changed, I end up binding whenever the page loads (Page_Load method). I've come to realise this is simply very bad - there are lots of times when the user can click various things in the page and have the page postback, and it takes an eternity to load each time I click something for accounts with lots of data.
Anyway, my question is essentially two-fold but I have a feeling the solution will be similar:
1: How can I detect when there are no accounts returned when searching, and disable the Grids/Detailsviews and show an error message?
2: How can I figure out when the user searches for another account and only rebind the grids after that has happened?
Thanks
This method is very ugly but it'll get the work done.
1) To Check whether there are no records; after the AutoComplete Extenders Webservice is called if no record is returned put some value in Session like
Session["NoData"]=true;
if Records are found then;
Session["NoData"]=false;
after the webservice is called do ajax request to check that session & on the basis of value do what you want.
2) You can achieve this also by following the above option.

Transferring Gridview data to another page

I have one page (Products) that searches for products which are then displayed in a gridview. Lovely stuff.
I then have a second page that is essentially a feedback form (Feedback). So therefore, a person should be able to search for a product, see its details in a gridview and then click on a hyperlink taking it to the feedback page. Upon arriving at the Feedback page, the product they were previously looking at (the gridview as it was) should be visible.
What I would like to do is transfer the gridview 'as is' (i.e. on what the person has searched for) to the second feedback page.
How would I go about achieving this?
Alternatively, if you could think of a better method for achieving the same effect (i.e. producing a feedback scenario), I am open to ideas. I could offer the feedback in the same page but I don't think it would be aesthetically pleasing with the page layout.
Please note, I appreciate that I could add an 'edit' element to the gridview itself but this is not approriate in this current scenario.
The simplest way to do this would be to make the original form and the feedback form the same ASPX page. You would simply hide or show elements, as you wish (using the Visible property). The grid view data would be persisted via ViewData.

Add control to Asp page and position in C#

I have a varying number of links that I need to add to a webpage using C#. A little background may help so, the ultimate goal of this is to have the user select an area of a map and choose the data they would like to get from this map. After the data reports have been generated, a link pops up for each area selected that is a download link for the report.
I can add new links fine, but I'd like to keep things centered on the page like the main control, but when I add a new hyperlink it keeps adding it to the left side. I have my page style set to centered and I don't see the option in a hyperlink object to set it's position. Is there any other way I can do this?
Forgive me but it's my first C# web app.
Thanks!
Make yourself a
<asp:PlaceHolder runat="server" id="plhFoo" />
In the location that you want to add your dynamic stuff to, and then add your controls to this, instead of the page.
-- Edit
If you want to position it, you may put a
<asp:Panel runat="server" ID="pnlFoo" CssClass="someclass" />
And style someclass; because the panel will render as a div.

Categories

Resources