Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-06-2009
Member
 
Join Date: Jun 2009
Posts: 197
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:-

Quote:
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);
Reply With Quote
  #2  
Old 04-06-2009
Member
 
Join Date: May 2008
Posts: 2,293
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:-

Quote:
<%@ 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>
Reply With Quote
  #3  
Old 04-06-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
Re: Issue with Clientscript Registerstartupscript

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

Quote:
<%@ 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 :
Quote:
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);
Reply With Quote
  #4  
Old 04-06-2009
Member
 
Join Date: Feb 2009
Posts: 391
Re: Issue with Clientscript Registerstartupscript

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

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Issue with Clientscript Registerstartupscript"
Thread Thread Starter Forum Replies Last Post
I have issue with the launching issue of Counter-strike Source Bhaanumuarti Video Games 6 12-06-2011 01:02 AM
DP35DP: memory issue; DVD issue; Lan issue. Rivan Motherboard Processor & RAM 5 29-06-2010 12:50 AM
Hardware issue or User Interface Issue HP Photosmart Plus B209a m Maadhav Portable Devices 4 03-04-2010 06:03 AM
DNS issue causing "Applying computer setting issue" hang NIcaBoy Small Business Server 2 14-10-2009 06:04 PM
Win 98 Issue Imanuel4u Windows Software 2 04-12-2008 11:41 AM


All times are GMT +5.5. The time now is 05:33 AM.