Array
(
)

ABRIR JANELA POPUP

Ricardoskype
   - 08 set 2008

Amigos,

Uso o RAD 2007 e gostaria de saber como faço para abrir uma janela pop-up a partir do clique de um botão em um form web.

Observação essa janela é para permitir q o usuário faça upload de imagens.

Grato


Pauloroger
   - 09 set 2008

Crie uma Lib:

unit uLib;

interface

uses System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls, System.Text,
System.Configuration, System.Web.Security;

{: habilita e desabilita controles }
procedure EnableDisableControls (aControls: ControlCollection; aValue: Boolean);
{: limpa controles de tela }
procedure ClearControls (aControls: ControlCollection);
{: abre uma nova janela no browser }
procedure OpenWindow (aPage: System.Web.UI.Page; aRedirect, aWidth, aHeight: string);
{: executa um script do JavaScript }
procedure ExecuteScript (aPage: System.Web.UI.Page; aScript: string);
{: mensagem com JavaScript }
procedure MessageScript(aPage: System.Web.UI.Page; aTexto: string);

implementation

procedure OpenWindow (aPage: System.Web.UI.Page; aRedirect, aWidth, aHeight: string);
var
aScript: StringBuilder;
begin
{: abre uma nova janela do browser }
aScript := StringBuilder.Create;
aScript.Append(´<script language=´JavaScript´>´);
aScript.Append(´window.open(´´+ aRedirect + ´´, ´´,´);
aScript.Append(´´resizable=no, menubar=no, scrollbars=yes, ´);
aScript.Append(´status=yes, left=350, top=150, width=´+ aWidth +
´, height=´ + aHeight + ´´)´);
aScript.Append(´</script>´);
if not aPage.IsClientScriptBlockRegistered(´client´) then
aPage.RegisterClientScriptBlock(´client´, aScript.ToString);
end;

procedure ExecuteScript (aPage: System.Web.UI.Page; aScript: string);
var
Script: StringBuilder;
begin
{: Execute script passado como parâmetro }
Script := StringBuilder.Create;
Script.Append(´<script language=´JavaScript´>´);
Script.Append(aScript);
Script.Append(´</script>´);
if not aPage.IsClientScriptBlockRegistered(´client´) then
aPage.RegisterClientScriptBlock(´client´, Script.ToString);
end;

procedure MessageScript(aPage: System.Web.UI.Page; aTexto: string);
var
Script: StringBuilder;
begin
{: mensagem com JavaScript }
Script := StringBuilder.Create;
Script.Append(´<script language=´JavaScript´>´);
Script.Append(´alert(´´+ aTexto + ´´);´);
Script.Append(´</script>´);
if not aPage.IsClientScriptBlockRegistered(´client´) then
aPage.RegisterClientScriptBlock(´client´, Script.ToString);
end;

procedure EnableDisableControls (aControls: ControlCollection; aValue: Boolean);
var
i, y: integer;
begin
{: habilita e desabilita controles }
for i := 0 to aControls.Count - 1 do
begin
{: controles de tela esta dentro de HTMLForm }
if (aControls.Item[i] is HtmlForm) then
begin
for y := 0 to aControls.Item[i].Controls.Count - 1 do
begin
if (aControls.Item[i].Controls.Item[y] is ImageButton) then
Continue;
if (aControls.Item[i].Controls.Item[y] is WebControl) then
(aControls.Item[i].Controls.Item[y] as WebControl).Enabled := aValue;
end;
end;
end;
end;

procedure ClearControls (aControls: ControlCollection);
var
i, y: integer;
begin
{: limpa controles de tela }
for i := 0 to aControls.Count - 1 do
begin
if (aControls.Item[i] is HtmlForm) then
begin
for y := 0 to aControls.Item[i].Controls.Count - 1 do
begin
{: controles mais comuns }
if (aControls.Item[i].Controls.Item[y] is TextBox) then
(aControls.Item[i].Controls.Item[y] as TextBox).Text := ´´;
if (aControls.Item[i].Controls.Item[y] is RadioButtonList) then
(aControls.Item[i].Controls.Item[y] as RadioButtonList).SelectedIndex := -1;
if (aControls.Item[i].Controls.Item[y] is DropDownList) then
(aControls.Item[i].Controls.Item[y] as DropDownList).SelectedIndex := -1;
if (aControls.Item[i].Controls.Item[y] is ListBox) then
(aControls.Item[i].Controls.Item[y] as ListBox).SelectedIndex := -1;
end;
end;
end;
end;

end.


No botão insira isso:
procedure TWebForm1.Button2_Click(sender: System.Object; e: System.EventArgs);
begin
OpenWindow(Page, ´pesquisaFuncionario.aspx´, ´500´, ´300´);
end;


Signori
   - 09 set 2008

ou...

simplesmente use um JavaScript, window.open... 8)