473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Call server site function into the javascript

70 New Member
Hi all,
I am creating a table at the runtime, which contains 4 rows and every rows contains 3 textboxes and a dropdownlist box. First when the page is loaded the table creates the 4 rows. I have also used a Linkbutton for adding more row. I want when I click that link button page should not be post back and add a new row. but when i click on the linkbutton it postbacks the page and the table again created and all the data in the textboxes are lost. So please tell me what should i do and i Linkbutton is medatory. We can also use <a> instead of linkbutton.

I have created a function for adding a new row in the table, and want to call that function in a javascript function and that javascript function should be called on the OnClientClick() event of linkbutton.
Oct 3 '07 #1
4 1723
Frinavale
9,735 Recognized Expert Moderator Expert
Hi all,
I am creating a table at the runtime, which contains 4 rows and every rows contains 3 textboxes and a dropdownlist box. First when the page is loaded the table creates the 4 rows. I have also used a Linkbutton for adding more row. I want when I click that link button page should not be post back and add a new row. but when i click on the linkbutton it postbacks the page and the table again created and all the data in the textboxes are lost. So please tell me what should i do and i Linkbutton is medatory. We can also use <a> instead of linkbutton.

I have created a function for adding a new row in the table, and want to call that function in a javascript function and that javascript function should be called on the OnClientClick() event of linkbutton.

LinkButtons are converted into <a href> tags when rendered in the browser.

Why are you having a problem adding the OnClientClick to the link button...

Here's an example of how to do it (through asp):
Expand|Select|Wrap|Line Numbers
  1.  <asp:LinkButton ID="Lbtn_MyLinkButton" runat="server" OnClientClick="myJavaScriptFunctionCall(); return false;" >  </asp:LinkButton>
You're going to need the "return false" in there to prevent the postback.

-Frinny
Oct 3 '07 #2
pankajprakash
70 New Member
ok, it's fine. I will call the myJavaScriptFunctionCall() on Client click but how can i call the that server site function which add the new row in the table.

LinkButtons are converted into <a href> tags when rendered in the browser.

Why are you having a problem adding the OnClientClick to the link button...

Here's an example of how to do it (through asp):
Expand|Select|Wrap|Line Numbers
  1.  <asp:LinkButton ID="Lbtn_MyLinkButton" runat="server" OnClientClick="myJavaScriptFunctionCall(); return false;" >  </asp:LinkButton>
You're going to need the "return false" in there to prevent the postback.

-Frinny
Oct 3 '07 #3
rsdev
149 New Member
ok, it's fine. I will call the myJavaScriptFunctionCall() on Client click but how can i call the that server site function which add the new row in the table.
To call the serve side function you need to post back to the server. You could do a partial post back using AJAX. Is this an option?
Oct 3 '07 #4
Frinavale
9,735 Recognized Expert Moderator Expert
ok, it's fine. I will call the myJavaScriptFunctionCall() on Client click but how can i call the that server site function which add the new row in the table.

You can't call a function on the server without a Postback...sorry.
But Rsdev has made a valid point....you could use Ajax to make an asynchronous call to the server's function.

Microsoft's put out ASP.NET Ajax...which is basically a framework that helps to implement Ajax into your ASP.NET project.
It's really helpful as it reduces a lot of coding that would have had to have been done by hand otherwise.

Check it out (you'll be interested in the Update Panel and set it's UpdateMode to Condition)

Cheers!
-Frinny
Oct 3 '07 #5

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

Similar topics

15
4177
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls...
1
5045
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
3
6763
by: David Shorthouse | last post by:
Hey folks, Not an off-topic posting.....since I was shot-down in an earlier post...this one's legit. How do I go about calling a server-side vbscript within a client-side javascript function?...
39
6477
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
4
4200
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
5
2574
by: settyv | last post by:
Hi, Below is the Javascript function that am trying to call from asp:Button control. <script language="javascript"> function ValidateDate(fromDate,toDate) { var fromDate=new Date();
3
3646
by: Angus | last post by:
I have a web page with a toolbar containing a Save button. The Save button can change contextually to be a Search button in some cases. Hence the button name searchsavechanges. The snippet of...
4
1472
by: bushi | last post by:
hi every one! i want to call a function of the code file into my javascript code.is it possible?how can i call it?any one knows about it plz rply me as soon as possible,any help will be...
5
9841
by: moni | last post by:
Hi.. I am trying to use javascript for google maps display. If I call the javascript function from my aspx file I use: <input type="text" id="addresstext" value="Huntington Avenue,...
4
3835
by: Ty | last post by:
Hello all, I am creating a web site with Visual Stuido 2008. I am trying to use a java script file to create a busybox for login from this page http://blogs.crsw.com/mark/articles/642.aspx. I...
0
7076
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
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
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
7453
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...
1
5005
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...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.