-
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:
- Cách cập nhật cấp độ câu hỏi trên web trắc nghiệm trực tuyến
- Tạo crystal report từ storeproduce
- Không kết nối được với cơ sở dữ liệu khi đăng kí vào trang web
- Cách đăng nhập bằng tài khoản Facebook trong web MVC3?
- Làm sao thay đổi trình duyệt mỗi khi debug website
- Làm website ASP.NET cho trang web Báo của chính Phủ liệu có mất phí?
- Xử lý kiểu dữ liệu Datetime trong ActionResult của MVC + Entity Framework, lỗi is not invalid for Birth day?
- Cách gán link có biến cho Button?
- Tạo đồ thị cho GridView như thế nào?
- làm sao kích thước của table trên masterpage không để cố định và kéo dãn tự nhiên được
-
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
Không chỉ dừng lại ở việc sử dụng nguyên liệu cao cấp, mỗi công trình còn được "chăm sóc" bằng 4 dịch vụ xuất sắc của Tre Nghệ. Từ việc tư vấn, thiết kế đến thi công và hoàn thiện, mọi quy trình đều...
Chất Lượng và Sáng Tạo: Kiến Trúc...