PFMMX PFMMX - 1 month ago 10
C# Question

Fire JS function from file in ASPX Code Behind

Suppose I have a reference to a .js in a master ASPX. In my code behind on the partial ASPX, I am populating a multiview with the details (CBL) of the entry the user selected.

I want to fire off a JS function from server-side depending on the selected state of the CB. I'm running into difficulty with the syntax for this, and sadly jquery isn't an option.

There are no errors to the console, nor is the JS breakpoint hit.

Page.ClientScript.RegisterStartupScript(this.GetType(), "someString", "Foo('" + CBL.ClientID + "')", true);


Anyone have any thoughts?

Answer

This was a bad architecture design by me. Since I am handling this during the initial page draw, I went ahead and handled it in the code behind.

Since the values were already recorded, I just ran everything through a series of switch statements. The key is to ensure that the controls are configured to runat="server".

Hope this helps someone else.