Results 1 to 4 of 4

Thread: Issue with Clientscript Registerstartupscript

  1. #1
    Join Date
    Jun 2009
    Posts
    199

    Issue with Clientscript Registerstartupscript

    I am using a script code on C# , asp.net2.0. What i want is to generate a report in new window on a click but its doing so, neither gives any error. Do any of you have any suggestion or idea about the same ? The code is here:-

    string Script= "<script type='text/javascript' language ='javascript' >";

    Script+= "window.open('PasswordRecovery.aspx',null,'resizeable=no,scrollbars=no,addressbar=no,toolbar=no,widt h=300,Height=250');";

    Script+= "</script>";

    Type csType = this.GetType();

    Page.ClientScript.RegisterStartupScript(csType, "PopupScript", Script);

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Issue with Clientscript Registerstartupscript

    I tried this, but it is working fine. I guess there must be some thing else wrong with you.I think u had given wrong file name. i'll suggest to check your code. Passing url for PasswordRecovery.aspx file name. Or just try this:-

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    string myScript = @"alert(document.forms[0]['TextBox1'].value);";
    Page.ClientScript.RegisterStartupScript(this.GetType(),
    "MyScript", myScript, true);
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" runat="server" Text="Hello ASP.NET"></asp:TextBox>
    </div>
    </form>
    </body>
    </html>

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Issue with Clientscript Registerstartupscript

    Or simply try this code, you will not need RegisterStartupScript for this task.

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
    protected void Page_Load()
    {
    StringBuilder sb = new StringBuilder();
    sb.Append("var box1 = document.getElementById('");
    sb.Append(TextBox1.ClientID);
    sb.Append("');");
    sb.Append("var box2 = document.getElementById('");
    sb.Append(TextBox2.ClientID);
    sb.Append("');");
    sb.Append("if (box1 != null && box1.value.length == 5 && box2 != null)");
    sb.Append("{");
    sb.Append("box2.focus();");
    sb.Append("}");
    TextBox1.Attributes.Add("onkeyup", sb.ToString());
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" runat="server" />
    <asp:TextBox ID="TextBox2" runat="server" />
    </div>
    </form>
    </body>
    </html>
    Or try this :
    string Script = "window.open('PasswordRecovery.aspx',null,'resizeable=no,scrollbars=no,addressbar=no,toolbar=no,widt h=300,Height=250')";
    Type csType = this.GetType();

    Page.ClientScript.RegisterStartupScript(csType, "PopupScript", Script, true);

  4. #4
    Join Date
    Feb 2009
    Posts
    391

    Re: Issue with Clientscript Registerstartupscript

    Did not get to .net 2 yet, but try Response.Write(myscript)

Similar Threads

  1. Replies: 6
    Last Post: 12-06-2011, 01:02 AM
  2. DP35DP: memory issue; DVD issue; Lan issue.
    By Rivan in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 29-06-2010, 12:50 AM
  3. Replies: 4
    Last Post: 03-04-2010, 06:03 AM
  4. DNS issue causing "Applying computer setting issue" hang
    By NIcaBoy in forum Small Business Server
    Replies: 2
    Last Post: 14-10-2009, 06:04 PM
  5. Win 98 Issue
    By Imanuel4u in forum Windows Software
    Replies: 2
    Last Post: 04-12-2008, 11:41 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,578,248.55383 seconds with 17 queries