Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
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.
Posted

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?

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...