Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to call an asp.net method with regular HTML input button

Posted on 2005-05-14
7
Medium Priority
?
384 Views
Last Modified: 2012-06-21
Hello, How can I call a method in an asp.net .vb (.dll) file from a html form submit button. This is what my button code looks like.

<input type="button" onClick="btnAsk_Click" value="Ask &#62;" class="submit" />

and I want it to call this method in that aspx page's codebehind document

     public Sub btnAsk_Click()
          ltlEmailOutput.Text = "test"
    End Sub

I can't use an asp.net web control because the code for the button is coming from an xslt document and throws errors when I try to add an asp.net web control. Figuring out how to put a web control in an xslt document may also solve my problem. But I think triggering this method with a normal submit button would be fine, any ideas?

Thank You,
Scott
0
Comment
Question by:sneidig
  • 3
  • 3
7 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 14004830
Is it on purpose that you have btnAskClick in your HTML, but btnAskFleet_Click in your codebehind?

Dabas
0
 

Author Comment

by:sneidig
ID: 14004833
That was a mistake. I made an edit to correct it that I think should show up. Thanks.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 14004856
The marriage between Xml Transforms and the event-driven model of ASP.NET can and has been done. But you must have a stronger grasp of reflection in order to do this. Also, can you perform the transformation (that is in during the Init event) early on?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sneidig
ID: 14004868
Now I know it can be done. Can you give me an idea of the learning curve for reflections? I found this tutorial http://www.xml.com/pub/a/2003/11/05/xslt.html though I'm not sure if it will help me or not.

I don't think I've ever put code in page_init if that's what you're refering too. I'm not sure how that would help me out.

Thanks for the info.
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 2000 total points
ID: 14004900
The learning curve is pretty steep and this is even with using C# (I realise that you are using VB.NET). But once you get the hang of it, such knowledge only serves to strenghten your grasp of the need for good design patterns. There is a hybrid also between Xml Transforms and the ASP.NET model
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 14004928
Youd need to change this:
<input type="button" onClick="btnAsk_Click" value="Ask &#62;" class="submit" />
to
<input type="button" onClick="btnAsk_Click" value="Ask &#62;" class="submit" runat="server" id="btnSubmit" />

You then get the text from the transformation and parse it like so:

Dim ctl As Control = Page.ParseControl(<txt>)
phText.Controls.Add(ctl)

Now comes the interesting part:
You can loop through the XmlDocument if there is one and hook up the events to methods within this class thru reflection since the output will definitely vary ....

or
you hardcode it like so
Dim btnSubmit As HtmInputButton = CType(ctl.FindControl("btnSubmit"),HtmlInputButton)
If Not btnSubmit Is Nothing Then AddHandler btnSubmit.Click, AddressOf Me.btnSubmit_Click


0
 

Author Comment

by:sneidig
ID: 14004935
Thank you. I'll have to continue working on this tomorrow. Have a good nite.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question