0

I would like to open a popup window using javascript in my c#.net app. This is the code in the body tag in my webform

<script language=javascript>
    function openWindow(strEmail)
    {        
    window.open('CheckEmail.aspx?email=' + strEmail + , 'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');
    return false;
    }
</script>

this is my code in the Page_Load section

this.btnCheck.Attributes.Add("onclick", "return openWindow(" + txtEmail.Text + ");");

right now I'm trying to pass the string from my textbox "txtEmail" so in my popup window i can get the request.querystring but Im a little unsure of how the syntax is.

2 Answers 2

1

No need of the last +

window.open('CheckEmail.aspx?email=' + strEmail,'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');

and in CheckEmail.aspx page you can get the query string as

Request.QueryString["email"]

Use a ' in the CS side inside the function around the textEmail.Text

this.btnCheck.Attributes.Add("onclick", "return openWindow('" + txtEmail.Text + "');");
Sign up to request clarification or add additional context in comments.

3 Comments

thanks rahul, the popup window managed to work but the address for the popup window is showing my email as undefined "CheckEmail.aspx?email=undefined"
You can to call the function like openWindow('[email protected]'); with quotes around the email address, or a variable that contains an email address and not null
actually my function is to take whatever the user entered in the textbox which in this case will be email address and check it against the database and this function will run in the Page_Load in my new popup window so it can inform the user if email exist. therefore its to grab the textbox string pass it as querystring to my new window and do my check in my new window
0

Why don't you get the email in the client code if the txtEmail control is visible.

function openWindow()
{  
   var email = document.getElementById('<%=txtEmail.ClientID%>').value;
   window.open('CheckEmail.aspx?email=' + email + , 'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');
   return false;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.