473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Getting started with AJAX and C#

45
Hi all I am new to AJAX. I am developing web application in ASP.NET C#. Please could any of you tell me how I am to go about using ajax for getting certain server values using the javascript. Please suggest articles that suite this scenario.

Many thanks.
Aug 23 '07 #1
9 1659
dmjpro
2,476 2GB
Hi all I am new to AJAX. I am developing web application in ASP.NET C#. Please could any of you tell me how I am to go about using ajax for getting certain server values using the javascript. Please suggest articles that suite this scenario.

Many thanks.

Please try some code.
Then come here with your specific problem.
Best of luck with your try.

Kind regards,
Dmjpro.
Aug 23 '07 #2
pbmods
5,821 Expert 4TB
Heya, Querry.

Changed thread title to better describe the problem (did you know that threads whose titles contain phrases such as, 'help' actually get FEWER responses?).

Have a look at this tutorial.
Aug 23 '07 #3
querry
45
Hi dmjpro and pdmods,

For dmjpro:
I am using the ASP.NET AJAX free library http://www.asp.net/ ]. I have two update panels.
In one update panel 1 I have, a textbox and a button. In update pannel 2 I have a ASP:Table. with no rows and cells.

What I want to do....
I want to add a TableRow and a TableCell with certain text taken from the textbox in the Update Panel 1 to the Table when the button is clicked.

What problems I face....
I am able to add a table row and a table cell to the table with the text specified in the textbox, but when I try to add another tacle row and table cell with a different text the first one gets replaced. This of course happens because the dynamically created controls do not persist after the postback. But I am not posting back. So I was expecting those controls to persist. But this does not happen.

What can be done? Can this be done with javascript??

For pdmods:
Oh! thanks for changing the title.

Thanks a lot!!

Cheers.
Aug 24 '07 #4
dmjpro
2,476 2GB
I am using the ASP.NET AJAX free library http://www.asp.net/ ]. I have two update panels.
In one update panel 1 I have, a textbox and a button. In update pannel 2 I have a ASP:Table. with no rows and cells.

What I want to do....
I want to add a TableRow and a TableCell with certain text taken from the textbox in the Update Panel 1 to the Table when the button is clicked.

What problems I face....
I am able to add a table row and a table cell to the table with the text specified in the textbox, but when I try to add another tacle row and table cell with a different text the first one gets replaced. This of course happens because the dynamically created controls do not persist after the postback. But I am not posting back. So I was expecting those controls to persist. But this does not happen.

What can be done? Can this be done with javascript??
Cheers.
You know the basic thing AJAX?
AJAX=>Asynchronous Java Script and XML.
And you need to be very strong on Java Script and XML.

Kind regards,
Dmjpro.
Aug 24 '07 #5
acoder
16,027 Expert Mod 8TB
What can be done? Can this be done with javascript??
Yes it can. Post your code so we can see the problem.
Aug 24 '07 #6
querry
45
Yes it can. Post your code so we can see the problem.
Sorry to be late....

Ok, I found out the solution but I am not sure that it is the right way to handle the problem. What I am doing is simple. I create a XML file at the first visit of the page in the Page load event after checking the IsPostback flag. If it is not a postback then I create a XML file. I save it to disk. In the event handler for the "Add Row" button I add the new controls to the table and make relevent tag entries for these controls in the XML file and save it. My XML file looks like this.

Expand|Select|Wrap|Line Numbers
  1. <Table ID="tblPage_1">
  2.       <TR ID="tr_1">
  3.         <TC ID="tc1_1" Text="1" />
  4.         <TC ID="tc1_2" Text="1" />
  5.         <TC ID="tc1_3" Text="1" />
  6.         <TC ID="tc1_4" Text="1" />
  7.       </TR>
  8.       <TR ID="tr_2">
  9.         <TC ID="tc2_1" Text="2" />
  10.         <TC ID="tc2_2" Text="2" />
  11.         <TC ID="tc2_3" Text="2" />
  12.         <TC ID="tc2_4" Text="2" />
  13.       </TR>
  14.       <TR ID="tr_3">
  15.         <TC ID="tc3_1" Text="3" />
  16.         <TC ID="tc3_2" Text="3" />
  17.         <TC ID="tc3_3" Text="3" />
  18.         <TC ID="tc3_4" Text="3" />
  19.       </TR>
  20.       <TR ID="tr_4">
  21.         <TC ID="tc4_1" Text="4" />
  22.         <TC ID="tc4_2" Text="4" />
  23.         <TC ID="tc4_3" Text="4" />
  24.         <TC ID="tc4_4" Text="4" />
  25.       </TR>
  26.     </Table>
Then in the coming postbacks I read the xml file and recreate the controls again.

So this solves the problem. I am not sure whether this is the most efficient way to do this. I was thinking of using something like xml serialization.

The pseudo code looks like this...

Expand|Select|Wrap|Line Numbers
  1. page_init()
  2. {
  3.   if(IsPostback == true)
  4.   {
  5.      //recreate the controls from the XML file.
  6.  }
  7. }
  8.  
  9. page_Load
  10. {
  11.  if(IsPostback != true)
  12.  {
  13.   //create a empty xml file.
  14.  }
  15. }
  16.  
  17. button_click()
  18. {
  19.   //Create and add new controls.
  20.  //open the XML file and add the elements/nodes representing the newly added controls.
  21. }
Now I have a new problem. Remember I am new to AJAX and have not use it here before. I want the table cells' background color to change when they are clicked. I need to add javascript to do that. How will I do that??

Many thanks.
Aug 30 '07 #7
acoder
16,027 Expert Mod 8TB
Glad you solved your problem.
Now I have a new problem. Remember I am new to AJAX and have not use it here before. I want the table cells' background color to change when they are clicked. I need to add javascript to do that. How will I do that??
Create a new thread for this - you won't need Ajax, just plain old DHTML. Boring, ain't it?
Aug 30 '07 #8
querry
45
Ok, let me explain more....

I am working on a web application which will be able to create forms. These forms will be stored in the XML form, in a database (MSSQL). Another web application will be able to access these XML forms and then recreate them from the XML files using the xsl files. To arrange the controls I need to place them in table cells. My xml forms will look something like this.

Expand|Select|Wrap|Line Numbers
  1. <form>
  2.       <table id=...>
  3.              <tr id=...>
  4.                    <tc id=...>
  5.                           <element id=......... type="Label" text="Some text" />
  6.                     </tc>
  7.                      <tc id=...>
  8.                           <element id=......... type="TextBox" text="" />
  9.                      </tc>
  10.                </tr>
  11.        </table>
  12. </form>
To place a Element inside a table cell I need to give a illusion that the cell is selected. Thats why I need to color the background in a different color. But the dynamic controls that are placed in the forms should appear to be placed without a postback. This is where, i belive, I need AJAX. If you have any comments please tell them to me. I will be glad to know them.

Many thanks again.

P.S.

Create a new thread for this - you won't need Ajax, just plain old DHTML. Boring, ain't it?
Hope its not boring now :)
Aug 31 '07 #9
acoder
16,027 Expert Mod 8TB
To change a table cell background colour, access the table cell (you could pass 'this' to a function) and set its style property:
Expand|Select|Wrap|Line Numbers
  1. tablecell.style.backgroundColor='#123456';
Aug 31 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Gustavo Amigo | last post by:
Hi, iīve started a project on sourceforge. Itīs called Ajax Pages, itīs a scripting template engine that enables rapid development of Ajax Web-based Applications. I would like you guys to take a...
5
by: GaryDean | last post by:
I have a 1.1 asp.net project that has been converted by the conversion wizard. By and large the app runs allright except for one page... On one of the .aspx pages, the code behind file is not...
1
by: kamleshsharmadts | last post by:
I am using Ajax with struts in web application. from jsp i am calling a function of ajax.js onclick of a button. code of that call function which calling from jsp given as below:- ...
2
by: dmagliola | last post by:
Hello all, I'm experiencing a problem with ASP.Net for which I can't find a reasonable explanation, or any information. I'm currently developing an application that, through AJAX, asks the...
6
by: Nathan Sokalski | last post by:
I am trying to start using the AjaxControlToolkit. I followed all the instructions on the following page: http://ajax.asp.net/ajaxtoolkit/Walkthrough/Setup.aspx The only thing I did...
8
by: alejrb | last post by:
Hi! I have a pretty simple AJAX request that just GETs the content of a page depending on a name that is fed to it. I'm parsing the page in quite a complex way, so I'm using the DOM to make it a...
17
by: Scott M. | last post by:
I'd like to start working with Ajax in VS 2008 Pro., but it's important that I not use anything that is not standard with VS 2008 Pro. (with all installation options selected). Does anyone have...
18
by: vjayis | last post by:
hi i have a php page in which i have included few tabs links like games, news,entertainment etc., when i click the tablink an ajax page is loaded below. In that ajax page several...
2
by: sukatoa | last post by:
Good day, Im new to JavaScript and would like also to learn Ajax by having experiments and to apply directly to an application(Hope this could also be effective) Now, i will attempt to conduct...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.