The most important part is Control which control in html tags you want to register the script for example if you have user control and you want to run the script just for that use this line.
Up vote 11 down vote favorite 1 share g+ share fb share tw.
The script will be in the head of the page... Type: "the type of the client script block" type? Its javascript. Why does he want another type from me?
Key: "a unique indentifier" That I can understand - for cases which later to remove... but I'd love for some more advanced explanations Can I have please , a real life scenario in which I TRULY have to play with those params? C# javascript .net scriptmanager registerclientscriptblock link|improve this question edited Nov 29 '11 at 7:59 asked Nov 28 '11 at 16:20Royi Namir10.9k1425 96% accept rate.
1 Nice question indeed. I was also wondering the same answers... – Braveyard Nov 28 '11 at 16:24.
The most important part is Control which control in html tags you want to register the script for example if you have user control and you want to run the script just for that use this line ScriptManager. RegisterStartupScript(this, this.GetType(), "alertscript", "document. GetElementById('userControl_h1TAG')", true); but when you want to register the block and script to all part of that page use this line in CS code of user-control : ScriptManager.
RegisterStartupScript(this. Page, this.Page.GetType(), "alertscript", "document. GetElementById('page_h1TAG')", true).
The javascript will have access to the whole html page, so you can access every element on the page even though you register it for the control. – Tomas Jansson Nov 29 '11 at 11:15 1 you are right but when you use UpdatePanel there will be problem link - – Mojtaba Pourmirzaei Nov 29 '11 at 11:31.
The method System.Web.UI.ScriptManager. RegisterClientScriptBlock calls behind the scenes to the internal method System.Web.UI. ScriptRegistrationManager.
RegisterClientScriptBlock that uses the parameter control to make a call to System.Web.UI. ClientScriptManager. RegisterClientScriptBlock by referencing control.Page.ClientScript.
RegisterClientScriptBlock. So, actually when you making a call like this: MyScriptManager. RegisterClientScriptBlock(this, this.GetType(), "alertScript", "alert('hi')", true); It's identical to calling: this.Page.ClientScript.
RegisterClientScriptBlock(this.GetType(), "alertScript", "alert('hi')", true); The type parameter comes handy when two different types trying to register scripts with identical string keys.
– Royi Namir Nov 29 '11 at 9:54 The method System.Web.UI. ClientScriptManager. RegisterClientScriptBlock generates internally a new key based on the values of the parameters type and key.
– Daniel Katz Nov 29 '11 at 9:59 what happens when two different types trying to register scripts with identical string keys? – Royi Namir Nov 29 '11 at 10:05 In such case ClientScriptManager registering TWO different script blocks with different keys. The key resolution works something like this: "TypeA_key", "TypeB_key".
– Daniel Katz Nov 29 '11 at 10:08 I think we both are wrong.... its combination of the control+type and not tpye+key – Royi Namir Nov 29 '11 at 10:14.
After looking on MSDN I found the method with slightly different parameters, but I think the answers should give you more insight: (msdn.microsoft.com/en-us/library/bb35075...) : Control: Client script blocks that are registered by using this method are sent to the page only when control represents a control that is inside an UpdatePanel control that is being updated. Type: This parameter is usually specified by using the typeof operator (C#) or the GetType operator (Visual Basic) to retrieve the type of the control that is registering the script. And I guess the key just is for making sure that one codeblock is not included twice?
Or it gives you a warning if you use the same key again?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.