Advertisement

04.13.2008 at 12:27AM PDT, ID: 23318240
[x]
Attachment Details

using "ClientScript.RegisterClientScriptBlock'

Asked by Relegence in Programming for ASP.NET, JavaScript, WebApplications

Tags: asp.net, c#, ie 7.0

Hello,

I am writing a c# asp.net application. I have a page with a "asp:LinkButton".
When pressing the linkButton I want to open another window by calling a javascript function using:

ClientScript.RegisterClientScriptBlock(this.GetType(), "openWin", "<script>openChannelsWin('newSection')</script>");

On 'openChannelsWin' function on client side, i am trying to fetch some values from controls on the screen, before opening the window, but then i get errors.

For example, I am trying to fetch the following value:
var siteName = document.getElementById("txtName").value;

The problem is that "document.getElementById("txtName")" is null and i get an exception.

The strange thing is that if I press "View Source" on my page, i do see all of the controls, but if i press the linkButton, i get an exception as if non of my controls are on the page.

What am I doing wrong here?

Thank you
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
My linkButton:
<asp:LinkButton ID="lnkSecChannels" runat="server" Text="Click to select channels..." OnClick="lnkSecChannels_Click"></asp:LinkButton>
 
My code behind function:
 protected void lnkSecChannels_Click(object sender, EventArgs e)
{
        ClientScript.RegisterClientScriptBlock(this.GetType(), "openWin", "<script>openChannelsWin('newSection')</script>");
}
 
My javascript function (openWin is a function i wrote):
function openChannelsWin(src)
{
var siteName = document.getElementById("txtName").value;            
openWin("../channels.aspx?siteName=" + siteName,'Channels','height=300')
}
[+][-]04.13.2008 at 02:39AM PDT, ID: 21344214

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, JavaScript, WebApplications
Tags: asp.net, c#, ie 7.0
Sign Up Now!
Solution Provided By: Irzana
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.13.2008 at 03:22AM PDT, ID: 21344268

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628