Wednesday, September 2, 2009

Vintage Barbara Weber Painting



Hello

After months of idleness leave a small example of how to start a popup from the server, well the trick is not very complex rather super easy but it will be very useful & # 160, someone that's for sure, I will place two ways to do it by placing the jscript popup trigger and the other using the registration form for q scripts run at startup de la pagina web

Con jscript en el botón q levanta el popup

  • Abran un nuevo web form coloquen un textBox y un Button
  • En el evento load del web form coloquen el siguiente código

    Dim s As String

    s =

    "popUp=window.open('webform2.aspx?" & _
    "&id=" & I . TextBox1.Text & _
    "','',' width = 860, height = 520, left = 40, top = 100, resizable = yes , status = yes, scrollbars = yes'); "

    I . Button1.OnClientClick =" javascript: " & s
  • Now add a second web form call
  • Add webforom2.aspx
  • a textbox and then in the load event of this new place the following webform

    Me.textbox1.text = Request.QueryString ( "Id" )

This example can something interesting is that if you write something in the textbox and call the popup, will not be transferred what they wrote, but if it will tighten again now if the text is transferred first to the second webform, this is because q script that raises the popup is "loaded" with the textbox in a subsequent postback, ie when you press the button for the first time are calling the form according to Previous state of the textbox, that the execution order makes first run the script jscript on the client and the postback occurs then you just load the contents of the textbox in the call to WebForm2. This detail is very important because if not handled well q will occur in this example, a lag of a postback in data passed to the second webform. To fix this do the following, place the textbox's AutoPostBack to true and ready, to leave the textbox with a postback will occur tab and jscript loaded correctly, then push the button and ready and works well.

Using the OnLoad event of the page when

Let's add a new WebForm to the project and will do almost the same as in the other, but use the click event of server-side button

  • the new webform add a textbox and a button as in the previous case
  • make 2 clicks to the button click event and put the following

    Dim s As
    String s =

    "window.open ( 'webform2.aspx? " & _
    " & id = " & Me . TextBox1.Text & _
    "','',' width = 860, height = 520, left = 40, top = 100, resizable = yes , status = yes, scrollbars = yes'); "

    Dim ss As String =" \u0026lt;script language = "" jscript "> & s & "</script>"

    Dim Pop As ClientScriptManager = Page.ClientScript
    Pop.RegisterStartupScript(
    Me .GetType(), "OnLoad" , ss)

Eso es todo, ahora ejecuten este nuevo webform carguen algo en el tetbox y opriman el botón, esta vez todo funciona perfectamente sin necesidad de colocar the AutoPostBack in the textbox, this is a very simple example, but serves to give a look at the popups, When they are using AJAX line: Pop.RegisterStartupScript ( I . GetType (), "OnLoad" , ss) should change it:

ScriptManager.RegisterStartupScript (

I , I . GetType, "OnLoad" , sScript, True )

well that's all I hope it helps someone


salu2 Sergio