Adding script to page from web control

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Hi,

In my simple web control I am trying to add the following script onto the page

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

Page.RegisterClientScriptBlock("ccr", "<SCRIPT Language=VBScript>" & vbCrLf & _
"function test(inp)" & vbCrLf & _

" alert ""hi"" " & vbCrLf & _

"end function")

MyBase.AddAttributesToRender(writer)

End Sub

I want this rendered out in to the page containing the web control.



But the script isnt rendering. I am using VS.NET 2003 w/ framework 1.1.



Can anyone help me out. Whats going wrong?



btw the web controls are still rendering fine.
 
put this code in OnPreRender, not in AddAttributesToRender, it serves another purposes

Hi,

In my simple web control I am trying to add the following script onto the page

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

Page.RegisterClientScriptBlock("ccr", "<SCRIPT Language=VBScript>" & vbCrLf & _
"function test(inp)" & vbCrLf & _

" alert ""hi"" " & vbCrLf & _

"end function")

MyBase.AddAttributesToRender(writer)

End Sub

I want this rendered out in to the page containing the web control.



But the script isnt rendering. I am using VS.NET 2003 w/ framework 1.1.



Can anyone help me out. Whats going wrong?



btw the web controls are still rendering fine.
 
ok i tried that but it still didnt work
put this code in OnPreRender, not in AddAttributesToRender, it serves another purposes

Hi,

In my simple web control I am trying to add the following script onto the page

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

Page.RegisterClientScriptBlock("ccr", "<SCRIPT Language=VBScript>" & vbCrLf & _
"function test(inp)" & vbCrLf & _

" alert ""hi"" " & vbCrLf & _

"end function")

MyBase.AddAttributesToRender(writer)

End Sub

I want this rendered out in to the page containing the web control.



But the script isnt rendering. I am using VS.NET 2003 w/ framework 1.1.



Can anyone help me out. Whats going wrong?



btw the web controls are still rendering fine.
 
ok cool i got it now,

so what is AddAttributesToRender for ?
put this code in OnPreRender, not in AddAttributesToRender, it serves another purposes

Hi,

In my simple web control I am trying to add the following script onto the page

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

Page.RegisterClientScriptBlock("ccr", "<SCRIPT Language=VBScript>" & vbCrLf & _
"function test(inp)" & vbCrLf & _

" alert ""hi"" " & vbCrLf & _

"end function")

MyBase.AddAttributesToRender(writer)

End Sub

I want this rendered out in to the page containing the web control.



But the script isnt rendering. I am using VS.NET 2003 w/ framework 1.1.



Can anyone help me out. Whats going wrong?



btw the web controls are still rendering fine.
 
basically, it is for adding attributes to tag that represents outer-most tag of your control, for example it could be span, div, or table

in AddAttributesToRender you could add something like width, onclick, or something like this to the outer-most tag of your control
 
Back
Top