![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, To my knowledge we can execute the javascript any where using RegisterStartupScript method. I have written the same javascript code in button click event and tried to execute using RegisterStartupScript metod in a composite custom control. I have written code to open another aspx page in that javascript. It didnt opened the page. But when debugging the code, it was going thru that code. If i execute the samne code using addattribute to that button control, its displaying the page as expected. Am I missing some thing. Here is the code I was trying to execute: void ctrlButton_Click(object sender, EventArgs e) { string strButtonClickScript = "javascript:var WinSettings = 'center:yes;resizable:no;dialogHeight:300px'; "; strButtonClickScript = strButtonClickScript + "var ParmA =''; "; strButtonClickScript = strButtonClickScript + "window.showModalDialog('http://localhost:4620/WebSite8/ Default3.aspx', ParmA, WinSettings)"; Page.ClientScript.RegisterStartupScript(this.GetTy pe(), scriptKey, strButtonClickScript); } The code thatz working: protected override void AddAttributesToRender(HtmlTextWriter writer) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "ctrlButton"); writer.AddAttribute("language", "javascript"); string strButtonClickScript = "javascript:var WinSettings = 'center:yes;resizable:no;dialogHeight:300px'; "; strButtonClickScript = strButtonClickScript + "var ParmA =''; "; strButtonClickScript = strButtonClickScript + "window.showModalDialog('http://localhost:4620/WebSite8/ Default3.aspx', ParmA, WinSettings)"; writer.AddAttribute("onclick", strButtonClickScript); } Thanks in Advance, Swapna. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |