-
29-12-2008, 08:02 AM #1Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Hiện Dialog trong ASP.net như thế nào?
cho mình hỏi : mình tạo 1 button , sau khi click vào button thì sẽ show lên thông dialog giống như trong C# dc vậy các bạn ? ( dialog yeso ok .....)
thanksView more random threads:
- Phân biệt RESTFUL vs MVC4 WebAPI?
- Cách tạo form popup trong ASP.NET để edit dữ liệu?
- Hiển Thị MessageBox trong ASP.Net có DialogResult như trong WinForm
- Tạo crystal report từ storeproduce
- Ý nghĩa getElementByID, getElementsByTagName, getElementsByName là gì?
- Connection giữa objectDB cache và ASP.NET
- Cách lấy chính xác ngày giờ hệ thống trong ASP.NET?
- lỗi Error The type or namespace name 'DbDataReader' could not be found (are you missing
- Cách không load lại khi chuyển trang?
- Cách truy cập List trong C# kết hợp với XAML (Silverlight)
-
29-12-2008, 09:08 AM #2Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Theo như zkday được biết thì trong ASP.NET không hỗ trợ dùng Dialog.
Vì trong javascript nó đã hổ trợ rồi.
Javascript run trên client, ASP.NET run trên Server.
Vậy nên muốn hiển thị dialogBox thì bạn dùng thằng javascript với hàm alert(xxx);
-
29-12-2008, 02:07 PM #3Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
thanks bạn , bạn có thể ghi cấu trúc của lệnh alert rõ ràng dc ko bạn
-
30-12-2008, 08:08 AM #4Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Gửi bởi trung
trước khi trả lời xin góp ý với bạn vài điều:
sao cậu không tự tìm hiểu những điều mình thắc mắc nhỉ[IMG]images/smilies/waiting.gif[/IMG], phải đợi người khác dâng đến tận nơi thì còn gì là thú vị của lập trình [IMG]images/smilies/redface.png[/IMG]
còn đây là 2 link về alert trong javascript.
http://www.tizag.com/javascriptT/javascriptalert.php
http://www.pageresource.com/jscript/jalert.htm
-
30-12-2008, 02:40 PM #5Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
thanks đã giúp đỡ [IMG]images/smilies/biggrin.png[/IMG]
-
05-03-2009, 06:33 PM #6Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Đừng hỏi cái gì , mà hãy hỏi tại sao . Rookie đã nói thía [IMG]images/smilies/biggrin.png[/IMG]
-
03-02-2015, 05:41 PM #7Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
một button, khi click vào hiện thị ra dialog thì trên mạng nhiều lắm bạn ạ.
- - - Nội dung đã được cập nhật ngày 03-02-2015 lúc 10:41 PM - - -
có lẽ cái này là cái bạn cần, muốn làm cho đẹp mắt thì bạn mất công thêm nữa.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="trang2.aspx.cs" Inherits="PopupProject.trang2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
#mask
{
position: fixed;
left: 0px;
top: 0px;
z-index: 4;
opacity: 0.4;
-ms-filter: "progid[IMG]images/smilies/biggrin.png[/IMG]XImageTransform.Microsoft.Alpha(Opacity=40)"; /* first!*/
filter: alpha(opacity=40); /* second!*/
background-color: gray;
display: none;
width: 100%;
height: 100%;</style>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function ShowPopup() {
$('#mask').show();
$('#<%=pnlpopup.ClientID %>').show();
}
function HidePopup() {
$('#mask').hide();
$('#<%=pnlpopup.ClientID %>').hide();
}
$(".btnClose").live('click', function () {
HidePopup();
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
DataKeyNames="ID" AllowPaging="true"
OnRowCommand="GridView1_RowCommand" PageSize="5"
onpageindexchanging="GridView1_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<%# Eval("ID") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="40" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:LinkButton ID="LinkButtonEdit" runat="server" CommandName="ShowPopup" CommandArgument='<%#Eval("ID") %>'>Edit</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" Width="40px"></ItemStyle>
</asp:TemplateField>
</Columns>
<PagerSettings PageButtonCount="5" />
</asp:GridView>
<div id="mask">
</div>
<asp:Panel ID="pnlpopup" runat="server" BackColor="White" Width="300px" Style="z-index: 111;
background-color: White; position: absolute; left: 35%; top: 12%; border: outset 2px gray;
padding: 5px; display: none">
<table width="100%" style="width: 100%; height: 100%;" cellpadding="0" cellspacing="5">
<tr style="background-color: #0924BC">
<td colspan="2" style="color: White; font-weight: bold; font-size: 1.2em; padding: 3px"
align="center">
Product Details <a id="closebtn" style="color: white; float: right; text-decoration: none"
class="btnClose" href="#">X</a>
</td>
</tr>
<tr>
<td colspan="2" style="width: 45%; text-align: center;">
<asp:Label ID="LabelValidate" runat="server" />
</td>
</tr>
<tr>
<td align="right" style="width: 45%">
ID:
</td>
<td>
<asp:Label ID="lblID" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="right">
Product Name:
</td>
<td>
<asp:TextBox ID="txtName" runat="server" />
</td>
</tr>
<tr>
<td align="right">
Price:
</td>
<td>
<asp:TextBox ID="txtPrice" runat="server" />
</td>
</tr>
<tr>
<td align="right">
Description:
</td>
<td>
<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Rows="5" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnUpdate" CommandName="Update" runat="server" Text="Update" OnClick="btnUpdate_Click" />
<input type="button" class="btnClose" value="Cancel" />
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>
*****************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Text;
namespace PopupProject
{
public partial class trang2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string sql = "select ID, Name from tblProducts";
GridView1.DataSource = LoadData(sql);
GridView1.DataBind();
Session["data"] = GridView1.DataSource;
}
}
static string cs = ConfigurationManager.ConnectionStrings["SQL"].ConnectionString;
private DataTable LoadData(string sql)
{
SqlConnection connect = new SqlConnection(cs);
SqlDataAdapter da = new SqlDataAdapter(sql, connect);
DataTable table = new DataTable();
connect.Open();
da.Fill(table);
connect.Close();
return table;
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ShowPopup")
{
LinkButton btndetails = (LinkButton)e.CommandSource;
GridViewRow grvrow =(GridViewRow)btndetails.NamingContainer;
lblID.Text = GridView1.DataKeys[grvrow.RowIndex].Value.ToString();
string sql = "select * from tblProducts where ID=" + Int32.Parse(lblID.Text);
DataTable table = new DataTable();
table = LoadData(sql);
txtName.Text = table.Rows[0]["Name"].ToString();
txtPrice.Text = table.Rows[0]["Price"].ToString();
txtDescription.Text = table.Rows[0]["Description"].ToString();
Popup(true);
}
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
if (txtPrice.Text == string.Empty)
{
Popup(true);
return;
}
SqlConnection connect = new SqlConnection(cs);
string sql = "update tblProducts set Name=@name, Price=@price, Description=@description where ID = " + Int32.Parse(lblID.Text);
SqlCommand cmd = new SqlCommand(sql, connect);
cmd.Parameters.AddWithValue("@name", txtName.Text);
cmd.Parameters.AddWithValue("@price", decimal.Parse(txtPrice.Text));
cmd.Parameters.AddWithValue("@description", txtDescription.Text);
connect.Open();
cmd.ExecuteNonQuery();
connect.Close();
Popup(false);
}
void Popup(bool isDisplay)
{
StringBuilder builder = new StringBuilder();
if (isDisplay)
{
builder.Append("<script language=JavaScript>ShowPopup(); </script>
");
Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "ShowPopup", builder.ToString());
}
else
{
builder.Append("<script language=JavaScript>HidePopup();</script>
");
Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "HidePopup", builder.ToString());
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = Session["data"];
GridView1.DataBind();
}
}
}
-
03-02-2015, 05:42 PM #8Junior Member
- Ngày tham gia
- Sep 2015
- Đang ở
- Hà Nội
- Bài viết
- 0
Đây là ví dụ của dialog box trong Client Site từ từ tham khảo nhé:
https://jqueryui.com/resources/demos...odal-form.html
Tuy nhiên, việc thi công và bảo dưỡng đường bê tông nhựa đòi hỏi sự chuyên nghiệp và kỹ thuật cao từ các nhà thầu và kỹ sư. Sự linh hoạt và độ bền cao của đường bê tông nhựa cũng giúp giảm thiểu chi...
Xây Dựng Đẳng Cấp: Cùng Đại Thanh,...