开发者

How to pass parameter when calling a .ascx control from javascript?

开发者 https://www.devze.com 2023-03-11 18:23 出处:网络
I am using this line to load the .ascx control after running a few javascrip开发者_Python百科t statements

I am using this line to load the .ascx control after running a few javascrip开发者_Python百科t statements

         __doPostBack('<%=Basket1.ClientID %>', null)

I do this then i get to the .ascx.cs file i run the code good..but can i pass parameter using the above line , and if i can how can i retrieve them on the ascx.cs page . I want to do it because even if i refresh the page the .ascx control loads and some code i dont want is executed so i need some check that when it is called from javascript it has some values and run the code . I hope you get what i want to say

Thank you


Ask yourself this: If I look at the flow (not the code, but the business flow), what information do I have when I am running the code one way that I don't when I run it another. If you figure that out, it is what has to be passed to the ASCX control.

Then there is the question of when you have to do it. The load of this variable has to be loaded prior to rendering the control.

ASCX controls are classes, like any other item in .NET, so setting it up as a property is fairly easy. If you head to a constructor argument, you end up with a dynamic loading issue, so I would not peruse that direction.

This page shows user controls with properties, which is an easy way to accomplish what you desire. To be safe, set a default for the property or choose to render an "error" (user friendly) when the property is not set. http://oreilly.com/catalog/progaspdotnet/chapter/ch14.html

0

精彩评论

暂无评论...
验证码 换一张
取 消