473,569 Members | 2,768 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 1728
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 myJavaScriptFun ctionCall() 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 myJavaScriptFun ctionCall() 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 myJavaScriptFun ctionCall() 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...sorr y.
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
4188
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 the function as:
1
5052
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 they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT...
3
6769
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? What I have is a page heavy on the javascript that has a number of functions, one of which is to begin a visual countdown with an onclick and also...
39
6499
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. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know...
4
4210
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 the server generates the HTML based on a passed in parameter. In our case, CustomerID. Every Customer ges a branded website with there logos and...
5
2578
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
3660
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 html is: <a class="searchsavechanges btn btn3d tbbtn" href="javascript:" style="position:static"> <div id="TBsearchsavechanges">Search</div> </a>
4
1475
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 appriciated
5
9846
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, Boston, MA" name="yourName" style="width: 287px" />
4
3846
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 am using a master page senerio. The erro I'm getting is 'busyBox' is not a member of 'ASP.login2_aspx'
0
7922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.