Facing difficulties: i'm looking for popup window for chat application in asp-c#
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>function Open() {");
sb.Append(string.Format("window.open('Chat.aspx?rid={0}'",lstRooms.SelectedValue));
sb.Append(, 'newwindow','toolbar=no,location=no,menubar=no,width=290,height=330,resizable=no,scrollbars=no,top=350,left=980,right=500'");return false;");
sb.Append("}</script>");
here is
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
i got error...too many characters in character literal...in this line
sb.Append(, 'newwindow','toolbar=no,location=no,menubar=no,width=290,height=330,resizable=no,scrollbars=no,top=350,left=980,right=500'");return false;");
thnks for guidence
i updated my question as above....plz help me
Facing difficulties: i'm looking for popup window for chat application in asp-c#
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>function Open() {");
sb.Append(string.Format("window.open('Chat.aspx?rid={0}'",lstRooms.SelectedValue));
sb.Append(, 'newwindow','toolbar=no,location=no,menubar=no,width=290,height=330,resizable=no,scrollbars=no,top=350,left=980,right=500'");return false;");
sb.Append("}</script>");
here is
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
i got error...too many characters in character literal...in this line
sb.Append(, 'newwindow','toolbar=no,location=no,menubar=no,width=290,height=330,resizable=no,scrollbars=no,top=350,left=980,right=500'");return false;");
thnks for guidence
i updated my question as above....plz help me
Share Improve this question edited May 1, 2012 at 6:46 mack28 asked Apr 30, 2012 at 10:12 mack28mack28 1292 gold badges7 silver badges20 bronze badges 4- is this will helps you ...codeproject./Questions/372479/… – Glory Raj Commented Apr 30, 2012 at 10:16
- i have developed it with using AJAX in asp.....i didn't got you ? – mack28 Commented Apr 30, 2012 at 10:17
- hiee all, i updated my thread so you can easily understand what i'm trying to do !! hope, u all help me.... thnks – mack28 Commented Apr 30, 2012 at 20:59
- thnks MUG4N sir for your instant helps.... – mack28 Commented May 1, 2012 at 7:37
3 Answers
Reset to default 2Here you can find a very easy and nice tutorial for popup with asp and ajax:
http://www.asp/web-forms/tutorials/ajax-control-toolkit/modalpopup/launching-a-modal-popup-window-from-server-code-cs
Hope it helps you.
Greetings
UPDATE:
this code is tested and works fine:
HTML:
<asp:Button ID="Button1" runat="server" OnClientClick="JavaScript:Open()" Text="Button" />
C#
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>function Open() {");
sb.Append(string.Format("window.open('Chat.aspx?rid={0}'", lstRooms.selectedvalue));
sb.Append(", 'newwindow','toolbar=no,location=no,menubar=no,width=290,height=330,resizable=no,scrollbars=no,top=350,left=980,right=500');return false;");
sb.Append("}</script>");
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
}
Of course you have to add the OnClick Attribute to your html button and point to the Open() Method.
The error message points to a specific error: in C# you need to enclose strings in double quotes. Single quotes are used to mean a single character.
string mystring = "This is a test";
Console.WriteLine(mystring[0] == 'T'); // prints "True"
According to the piler you tried to enclose a string in single quotes.
While linking the stylesheet/javascript/jquery avoid using runat="server" inside the tag.
If we include runat="server". It may also leads to the above mentioned error.