mRbLACK Posted December 22, 2003 Posted December 22, 2003 Hi there Is it possible (and how) to call an asp.net function from a non asp.net tag ie. calling a function from <button> tag instead of an <asp:button> tag? I know this is a basic question but its really irritating me. thanks Quote
jeffchs Posted December 22, 2003 Posted December 22, 2003 I don't think it is possible since the code is only on the server side. maybe adding a runat="server" attribute in the button would work, but I doubt it. you could have the button repost to the same page with a modified URL adding a ?myvariable=myvar then have your page load function check for this variable and call the function from the pageload. Quote
*Gurus* Derek Stone Posted December 22, 2003 *Gurus* Posted December 22, 2003 You can cause a postback from any element that supports an onclick event (JavaScript). Quote Posting Guidelines
mRbLACK Posted December 23, 2003 Author Posted December 23, 2003 thanx i assumed its possible but havent found the right code yet, if your vb function is myfunc() <button value="submit" onclick="myfunc"> <button value="submit" onclick="myfunc()"> <button value="submit" onclick="myfunc" runat="server"> non of it works (not to mention there is no runat attrb for those tags) any ideas? Quote
bungpeng Posted December 23, 2003 Posted December 23, 2003 No, you cannot direct call your vb function "myfunc" like this. You can cause a Postback, then in your server "Page_load" event, use "Request.Form..." (not runat=server) to check which controls cause the Postback, then call the necessary functions. Example: If Request.Form("btnSave") = "Save" Then Call SaveFunc ElseIf Request.Form("btnDelete") = "Delete" Then Call DeleteFunc End If Quote
mRbLACK Posted December 23, 2003 Author Posted December 23, 2003 geees what a shlepp but that makes a lot more sence thanks loads for the help...:D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.