There may come a time when there is a requirement that a web part be used multiple times on a web page.
Often, depending on the behavior of the web part, the web part/s may function incorrectly.
There was a web part I developed and the business user needed it to be displayed more than once on a page. My web part contained JavaScript as well as server side code.
SOLUTION: A solution would be to attach the web part ID to each JavaScript method and call. Hence making each instance of the same JavaScript method unique. If you have two of the same web parts on the page, each of those web parts will have a different web part ID. Web Part A will be calling Web Part A JavaScript Method and Web Part B will be calling Web Part B JavaScript Method.
Also attach the web part ID to the RegisterStartUpScript name. This will prevent your second JavaScript overwriting your first JavaScript method. If this happens, you will get JavaScript errors if you try to do something on your first web part because the methods it needs to call are missing.
As long as methods all have unique names, and on post back you are checking for the EventArgument correctly. You can attach a hashed string containing the post back argument parameter '#' web part ID.
Subscribe to:
Post Comments (Atom)
.jpg)

No comments:
Post a Comment