link ASP.NET function from HTML
-
hi... can somone pls tell me how can i link an ASP.NET function from HTML code?? like when i need to lik to a JS code i do this
<~a href=""javascript:SortHeader();"">Status(Active/Inactive)<~/a~>(without the ~)
so what should i do if i need to link to an ASP.NET function?? my asp.NET function resides in a MyFunction.vb and the function name is callHeader can someone pls tell me how can i call- myfunction.callHeader from html code to make a link from ?? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18 -
hi... can somone pls tell me how can i link an ASP.NET function from HTML code?? like when i need to lik to a JS code i do this
<~a href=""javascript:SortHeader();"">Status(Active/Inactive)<~/a~>(without the ~)
so what should i do if i need to link to an ASP.NET function?? my asp.NET function resides in a MyFunction.vb and the function name is callHeader can someone pls tell me how can i call- myfunction.callHeader from html code to make a link from ?? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18Hello: Actually you can´t call it directly. If Your intention is (and i guess it´s not) to execute that function without doing a postback, you just can't do that. (I interpreted that the function you want to call is a .NET one -should run at server side- not a client one) Now what yo can do is to use a Webform LinkButton control and on it´s OnClick event handler call the funtion you want to execute (there can be other approaches but that´s the simplest)
-
Hello: Actually you can´t call it directly. If Your intention is (and i guess it´s not) to execute that function without doing a postback, you just can't do that. (I interpreted that the function you want to call is a .NET one -should run at server side- not a client one) Now what yo can do is to use a Webform LinkButton control and on it´s OnClick event handler call the funtion you want to execute (there can be other approaches but that´s the simplest)
you are correct.. its a dotnet function and its a server side function too... but i dont want to use a button... i have to use a link... anyway i can achieve this through a link instead of a button?? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
you are correct.. its a dotnet function and its a server side function too... but i dont want to use a button... i have to use a link... anyway i can achieve this through a link instead of a button?? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Ok but the LinkButton looks like a link ...it IS a link (the Button part of the name is ´cause it has the CommandName & CommandArgument properties just as buttons has them but for nothing else). If you insist in using a "real" link then you "only" have to attach its href to some javascript function in which you fill the value of a hidden field ,and submit the form by your own, Then in code behind ask for that value in the Page_Load, and if the value is set you execute your function... ...As you can see it is a very dirty solution but the Hyperlink control and the ones you can make in html through the format menu don´t have events associated and they don´t do postbacks to the server when clicked...so other approaches should be similars to this one... if someone has a cleaner way, please post it. My suggestion : use the LinkButton control and you'll only need a single line of code in which you´ll call your function.
-
hi... can somone pls tell me how can i link an ASP.NET function from HTML code?? like when i need to lik to a JS code i do this
<~a href=""javascript:SortHeader();"">Status(Active/Inactive)<~/a~>(without the ~)
so what should i do if i need to link to an ASP.NET function?? my asp.NET function resides in a MyFunction.vb and the function name is callHeader can someone pls tell me how can i call- myfunction.callHeader from html code to make a link from ?? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18 -
Ok but the LinkButton looks like a link ...it IS a link (the Button part of the name is ´cause it has the CommandName & CommandArgument properties just as buttons has them but for nothing else). If you insist in using a "real" link then you "only" have to attach its href to some javascript function in which you fill the value of a hidden field ,and submit the form by your own, Then in code behind ask for that value in the Page_Load, and if the value is set you execute your function... ...As you can see it is a very dirty solution but the Hyperlink control and the ones you can make in html through the format menu don´t have events associated and they don´t do postbacks to the server when clicked...so other approaches should be similars to this one... if someone has a cleaner way, please post it. My suggestion : use the LinkButton control and you'll only need a single line of code in which you´ll call your function.
can u tell me how i can do it if i use linkbutton??? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
You can do it easily Josesh, I don't rememeber the exact syntax now but its something like this: [/> Maybe others correct this or you can find correct syntax with googling.](<%#functionnameincodebehind()%)
i tried it..... doesn't work... :( "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
i tried it..... doesn't work... :( "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Joseph R. Thomas wrote: doesn't work... I told you that its not the exact one , you can find exact solution with seaching or waiting for someone else or me to go home ans see the correct solution,but don't worry its not hard one. Mazy "A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
-
Joseph R. Thomas wrote: doesn't work... I told you that its not the exact one , you can find exact solution with seaching or waiting for someone else or me to go home ans see the correct solution,but don't worry its not hard one. Mazy "A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
tks a lot....but if i search for wat keyword should i search for?? i mean what is this thing called?? linking?? or something??:confused: tks a lot... :) "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
can u tell me how i can do it if i use linkbutton??? tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Well... as you seem to like throwing a lot of code here we go : LOL In this page i´ve put a Hyperlink control if the link you desire is one of those you get via the Format menu after selecting the text the only thing you have to change is to assign its href property to the same value the link i give you has in its NavigateUrl property.... Also I´ve put a hidden field and have set its runat=server... And the function myfunc which sets the value of the hidden field and does the submit..Notice it is called in the NavigateURL property (which will be the href attribute when the page is rendered) in summary what you have to do. 1.Put your hyperlink 2.put a hidden field (named Hid in the example)and set it to Run at server (runat="server") 2.Write a function similar to the one called "myfunc" i wrote in the aspx code (basically you won´t need to change it) 3 Set your hyperlink's NavigateURL="javascript:myfunc();" That´s all in the aspx page Now in codebehind 1. In Page_load check the value of the hidden field 2.If it is ="1" call your function 3. Reset the Hidden field value to "0" otherwise your function will be executed when any control (not just the hyperlink) produces a postback after the first time the hyperlink is pressed The aspx code follows:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebTests.WebForm1"%> WebForm1 function myfunc() { document.Form1.Hid.value="1"; Form1.submit(); } HyperLink Label
Then in the server side (i gave you a .vb file, in .cs is the same thing with the proper sintax) The server function i provided just adds an A character to t -
You can do it easily Josesh, I don't rememeber the exact syntax now but its something like this: [/> Maybe others correct this or you can find correct syntax with googling.](<%#functionnameincodebehind()%)
I´m afraid it´s not possible since: 1. The hyperlinks controls (not the LinkButton) don´t do postback when clicked 2. Regardless of that, You are attempting to call a server function from the client side Anyway I searched a little and there's nothing similar to the function you suggested. If you know it is possible in a way similar to that one you propossed(i really doubt it) could you put the right way here please? Regards
-
I´m afraid it´s not possible since: 1. The hyperlinks controls (not the LinkButton) don´t do postback when clicked 2. Regardless of that, You are attempting to call a server function from the client side Anyway I searched a little and there's nothing similar to the function you suggested. If you know it is possible in a way similar to that one you propossed(i really doubt it) could you put the right way here please? Regards