tonelm54
asked on
Adding Attribute after comile returns '
Good evening,
Ive been trying to add a javascript methods to a textbox on my aspx page. I have used the two lines below to add the javascript functions to the textbox:-
TextBox1.Attributes.Add("o nFocus", "javascript: showDiv(this, 'divBelowObjects');")
TextBox1.Attributes.Add("o nBlur", "javascript: hideDiv('divBelowObjects') ;")
But when I run the code, it fails with an 'Invlid character' on the following line:-
<input name="ctl00$MainContent$Te xtBox1" type="text" id="MainContent_TextBox1" onFocus="javascript: showDiv(this, 'divBelowObjects') ;" onBlur="javascript: hideDiv('divBelowObjec ts');" />
What I dont understand is why asp is converting ' into ' ???
Any ideas how I can run my code with ' instead of '???
Thank you
Ive been trying to add a javascript methods to a textbox on my aspx page. I have used the two lines below to add the javascript functions to the textbox:-
TextBox1.Attributes.Add("o
TextBox1.Attributes.Add("o
But when I run the code, it fails with an 'Invlid character' on the following line:-
<input name="ctl00$MainContent$Te
What I dont understand is why asp is converting ' into ' ???
Any ideas how I can run my code with ' instead of '???
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try using double quotes instead of single quotes like:
TextBox1.Attributes.Add("o
TextBox1.Attributes.Add("o
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have tried:-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o nFocus", "javascript: showDiv(this, ""divBelowObjects"");")
TextBox1.Attributes.Add("o nBlur", "javascript: hideDiv(""divBelowObjects" ");")
End Sub
Which runs as:-
<input name="ctl00$MainContent$Te xtBox1" type="text" id="MainContent_TextBox1" onFocus="javascript: showDiv(this, "divBelowObjects" ;);" onBlur="javascript: hideDiv("divBelowObje cts") ;" />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o
TextBox1.Attributes.Add("o
End Sub
Which runs as:-
<input name="ctl00$MainContent$Te
ASKER
I have tried:-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o nFocus", "javascript: showDiv(this, \'divBelowObjects\');")
TextBox1.Attributes.Add("o nBlur", "javascript: hideDiv(""divBelowObjects" ");")
End Sub
Which runs as:-
<input name="ctl00$MainContent$Te xtBox1" type="text" id="MainContent_TextBox1" onFocus="javascript: showDiv(this, \'divBelowObjects\' ;);" onBlur="javascript: hideDiv("divBelowObje cts") ;" />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o
TextBox1.Attributes.Add("o
End Sub
Which runs as:-
<input name="ctl00$MainContent$Te
ASKER
When I try:-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o nFocus", "javascript: showDiv(this, \"divBelowObjects\");")
TextBox1.Attributes.Add("o nBlur", "javascript: hideDiv(\"divBelowObjects\ ");")
End Sub
I get:-
Comma, ')', or a valid expression continuation expected.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("o
TextBox1.Attributes.Add("o
End Sub
I get:-
Comma, ')', or a valid expression continuation expected.
Regards,
Raja Muthaiah