字符太多字符asp.net C#字面 [英] too many characters in character literal in asp.net c#
问题描述
面临的困难:
我正在寻找在asp.net 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());
}
if (!ClientScript.IsClientScriptBlockRegistered("JSScriptBlock"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "JSScriptBlock", sb.ToString());
}
我有错误...字符的太多字符文字 ...在此行
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
thnks for guidence
我更新了我的问题,如上.... plz帮助我
i updated my question as above....plz help me
推荐答案
在这里,你可以找到一个很容易和漂亮的教程与弹出和asp.net阿贾克斯:
Here you can find a very easy and nice tutorial for popup with asp.net and ajax:
<一个href=\"http://www.asp.net/web-forms/tutorials/ajax-control-toolkit/modalpopup/launching-a-modal-popup-window-from-server-$c$c-cs\" rel=\"nofollow\">http://www.asp.net/web-forms/tutorials/ajax-control-toolkit/modalpopup/launching-a-modal-popup-window-from-server-$c$c-cs
希望它可以帮助你。
问候
更新:
这code测试和工程罚款:
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());
}
}
当然,你必须添加onclick属性到HTML按钮,指向open()方法。
Of course you have to add the OnClick Attribute to your html button and point to the Open() Method.
这篇关于字符太多字符asp.net C#字面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!