用户单击图像(或图像按钮)时如何更新数据库? [英] How do I update a database when users click an image (or image button)?

查看:94
本文介绍了用户单击图像(或图像按钮)时如何更新数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些访客喜欢发表评论;所以我设计了一个简单的ASP网页表单,用户输入他们的电子邮件和评论。老板告诉我将他们的回复存储在Microsoft Access数据库中。



为了保持视觉导航的一致性,最好使用看起来像并且表现得像的图像一个花哨的提交按钮来插入数据。现在,它作为ASP image_button在页面上。真正的初学者问题:他们点击的图像应该在表格内还是在图片下面?



接下来,我对单击事件的了解不足以让它工作。我猜测点击应该从页面加载调用外部代码文件来进行实际插入。沿着这些方向,我不知道如何引用文本框的内容来完成工作。



你可以帮助的任何进展都是这一步接近。万分感谢。

解决方案

第一个链接包含如何创建联系表单,第二个链接包含如何通过ASP.NET C#访问Ms女士。< br $> b $ b

http:// www.aspnettutorials.com/tutorials/email/add-contactus-form-asp-csharp/ [ ^ ]



http://stackoverflow.com/questions/15586441/adding-data-in -the-database-using-microsoft-access-and-oledb-in-c-sharp [ ^ ]



享受.. :))
否。时钟图像与表格无关。只有具有提交按钮和一些具有状态和名称的控件时才需要表单。 HTTP请求被发送到 action 页面,名称用于创建用作HTTP请求中的数据的名称 - 值对。鉴于此,浏览器本身会发送适当的HTTP请求,因此除了HTML之外,您不需要进行任何编码。



图像没有状态,你可以只处理它的点击事件。但是,如果你在表单上有它,那就是没有提交效果的单独事件。您可以编写处理事件的任何JavaScript代码(事件侦听器),但启动某些HTTP请求的唯一方法是使用AJAX: http://en.wikipedia.org/wiki/Ajax_(programming) [< a href =http://en.wikipedia.org/wiki/Ajax_(programming)\"target =_ blanktitle =New Window> ^ ]。



因此,正如您所看到的,您可以在图像点击(或任何其他元素)上发送一些HTTP请求,但它与表单无关。在处理程序中,您可以收集任何控件上的任何数据并将此数据包含在请求中,但是如果某些控件是表单的子控件并不重要,则它们可以是任何控件。它与表格无关。



我解释逻辑,你可以考虑如何处理它。这是您的代码设计问题。从UI设计的角度来看,表单是不可见的。对于用户而言,某些控件与表单相关的方式完全无关紧要。如果您已经使用了AJAX,则可以保持HTML不受任何形式的影响,明确地形成所有HTTP请求。你决定。



-SA


Some visitors like to leave comments; so I designed a simple ASP web form where users input their e-mail and their comment. the boss told me to store their responses in a Microsoft Access database.

To keep visual navigation consistency, it would be best to use an image that looks like and acts like a fancy submit button to insert the data. Right now, it's on the page as an ASP image_button. True Beginner Question: should the image they will click go inside the form or below it?

Next, I don't know enough about click events to get it to work. I'm guessing the click should call an external code-file from page-load to do the actual insert. And along those lines, I don't know how to reference the contents of the textboxes to get the job done.

Any progress you can help with moves this one step closer. Thanks a million for giving it.

解决方案

First link contains how to create a contact form and second link contains how to access Ms. Access through ASP.NET C#.

http://www.aspnettutorials.com/tutorials/email/add-contactus-form-asp-csharp/[^]

http://stackoverflow.com/questions/15586441/adding-data-in-the-database-using-microsoft-access-and-oledb-in-c-sharp[^]

Enjoy.. :)


No. An image to clock has nothing to do with forms. A form is only needed when it has a submit buttons and some controls with states and names. The HTTP request is sent to action page, and names are used to create name-value pairs used as data in the HTTP request. Given all that, appropriate HTTP request is sent by the browser itself, so you don't need to do any coding except HTML.

An image does not have states, you can just handle its click event. But, if you have it on the form, it's the separate event which does not have an effect of submit. You can write any JavaScript code handling the event (event listener), but the only way to initiate some HTTP request would be using AJAX: http://en.wikipedia.org/wiki/Ajax_(programming)[^].

So, as you can see, you can sent some HTTP request on image click (or any other element), but it has nothing to do with forms. In the handler, you can collect any data on any controls and include this data in the request, but it does not matter if some controls are children of the form or not, they can be any control. It has nothing to do with forms.

I explain the logic, you can think at what to do with it. It's a matter of your code design. From the standpoint of UI design, a form is something invisible. For the user, it's absolutely irrelevant how some controls are related to the forms. If you already use AJAX, you can keep your HTML free of any forms at all, forming all HTTP requests explicitly. You decide.

—SA


这篇关于用户单击图像(或图像按钮)时如何更新数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆