Popup In Datalist

liunx

Guest
Hello

Can anybody teach me how to create a popup button in a datalist and how to pass it to javascript which use to do popup function ??
any help will be appreciateTry this

<script language="javascript">
function newWin() {
myWin = window.open("URL", "winName", "Pref");
}
</script>
<forum runt="server">
<asp:DataList
ID="DataList1"
Runat="Server">

<ItemTemplate>
<asp:button id="Button1" text="newWin" runat="server" />
</ItemTemplate>

</asp:DataList>
</forum>
ASP.NET Code (after binding to DataList):
for (i = 0; i < DataList1.Items.Count; i++) {
Button Btn = (Button)DataList1.Items.FindControl("Button1");
Btn.Attributes.Add("onClick", "myWIn()");
}
that code assuming you wont pass arguments to javascript function.thanks it worksAnother question.....

is it posible that a new window is pop up when the main page is load ???you can do it in body tag
<body onLoad="newWin()">i just want to code it in vb.net page load. Is it posible ???try this
Dim Script As String
Script = "<script langauge='javascript'>"
Script &= "window.open('URL', 'winName', 'Pref');"
Script &= "</script>"
RegisterStartupScript("any name", Script);i tried your example but it doesn't work . I even tried this ......

Dim Script As String
Script = "<script langauge='javascript'>"
Script = Script & "window.open('URL', 'winName', 'Pref');"
Script = Script & "</script>"
RegisterStartupScript("any name", Script)Try this
RegisterClientScriptBlock("anyName", Script)
Or
Response.Write(Script)i had tried response.write(Script) but it do not come out any output ..
The example that you give me is work but the popup window is block. It only works when i click Ctrl button follow by refresh button. I had already set allow popup but it still cannot work. Any idea to solve this problem???
 
Back
Top