从数据库访问表单时出现问题 [英] Problem in Form accessed from database

查看:87
本文介绍了从数据库访问表单时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站有两个部分,管理员和用户.
在管理部分中,我使用的是ckfinder,它会填充管理部分中的首页"和与我们联系"之类的页面.
主页"和联系我们"页面的内容存储在数据库中.
在用户部分中,我只是通过数据库按其各自的ID(在后面的代码中)显示这些填充的页面.
一切正常.
但是问题是这样的:
在与我们联系"页面中,我需要它,如果用户填写了与我们联系"表单并单击提交"按钮,则应显示消息,表明记录已填写.
Contactus表单的内容存储在数据库中.
内容如下:
崩溃

My website has two sections, admin and user.
In admin section I am using ckfinder which fills pages like ''home'' and ''contact us'' in the admin section.
The ''home'' and ''contact us'' page content is stored in a database.
In the user section I am just displaying these filled pages through database by their respective id in code behind.
All is working fine.
But problem is this:
In the ''contact us'' page I need it that if the user fills contact us form and clicks on submit button then the message should be displayed showing that the record is filled.
The contactus form content is stored in database.
The content is like:
Collapse

<label>Name:</label><input id="uname" name="uname" type="text" /><br />
    <br />
    <label>Phone:</label><input id="phone" name="phone" type="text" /><br />
    <br />
    <label>Email:</label><input id="email" name="email" type="text" /><br />
    <br />
    <label>Message:</label><textarea cols="40" id="msg" name="msg" rows="10"></textarea><br />
    <br />
    <label> </label><input type="submit" value="Submit"  onserverclick="submit_onclick"   runat="server"   /><asp:Button

        ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />



此内容存储在数据库中并显示在用户部分.
显示了控件和按钮,但是如何调用数据库中的click事件?
在联系我们表格的后面代码中,我使用了:



This content is stored in database and displayed in user section.
The control and button displayed, but how can I call the click event which is in database?
In code behind of contact us form I used:

WebPageContent obj = new WebPageContent();
        divContent.InnerHtml = obj.getContent(5);

推荐答案

不使用ASP.NET为您提供的功能. ASP.NET具有服务器控件,这些控件可以绑定在一起,而不是像看起来那样创建和替换原始html元素.

如果您希望在按钮后显示一条消息,请在您的页面上放置一个Label控件,并将其初始可见性设置为false.在按钮click事件处理程序中,将其设置为true.
It appears you are not using ASP.NET for what it give you. ASP.NET has server controls which can be bound to rather creating and replacing raw html elements as it appears you are doing.

If you want a message to be displayed after the button click then place a Label control on your page with initial visibility set to false. In the button click event handler set it to true.


这篇关于从数据库访问表单时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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