asp.net causing line breaks in javascript

  • Thread starter Thread starter Sasha Shevelev
  • Start date Start date
S

Sasha Shevelev

Hi there,

I can;t believe no one else has had this prob but here goes...

I add some javascript into my page and asp.net sometimes (not always) puts
the js into my page with a line break rendering it useless...


Here is my code...

Dim txtDetails As TextBox = CType(e.Item.FindControl("txtDetails"), TextBox)
'Create the javascript string

strJS ="javascript:ExtendedNotes_window=window.open('extendednotes.aspx?key=" & key & "','ExtendedNotes_window','scrollbars=no,width=480,height=300');ExtendedNotes_window.focus()"

txtDetails.Attributes.Add("onClick", strJS)



Here is the source wjhen it runs.....

When it works the source code looks like (take wrapping off) - <input name="dgrdTimeSheet:_ctl2:txtDetails" type="text" maxlength="20" readonly="readonly" id="dgrdTimeSheet__ctl2_txtDetails" class="soft" onClick="javascript:ExtendedNotes_window=window.open('extendednotes.aspx?key=18C2B4EB-F8B3-462B-AB74-7307D54DBEF7','ExtendedNotes_window','scrollbars=no,width=480,height=300');ExtendedNotes_window.focus()" style="width:80px;" />

When it doesn't - <input name="dgrdTimeSheet:_ctl2:txtDetails" type="text" maxlength="20" readonly="readonly" id="dgrdTimeSheet__ctl2_txtDetails" class="soft" onClick="javascript:ExtendedNotes_window=window.open'extendednotes.aspx?key=18C2B4EB-F8B3-462B-AB74-7307D54DBEF7
<puts line break here>
','ExtendedNotes_window','scrollbars=no,width=480,height=300');ExtendedNotes_window.focus()" style="width:80px;" />

This obviously causes unterminated string constant. It's not the editor I view my source in either. I saw another posting similar to mine and the guy had checked all the characters but no one provided an answer to him.

This is really urgent. Can anyone help????

Thanks,

Sasha
 
I have no explanation for you, but here's a possible workaround:


Dim jsNoteWin As String
jsNoteWin = "<script language='javascript'>" & vbNewLine & _
"<!--" & vbNewLine & _
"function OpenNoteWin( key) {" & vbNewLine & _
" var url;" & vbNewLine & _
" url = 'extendednotes.aspx?key=' + key;" &
vbNewLine & _
" ExtendedNotes_window=window.open( url,
,'ExtendedNotes_window','scrollbars=no,width=480,height=300');" & vbNewLine
& _
" ExtendedNotes_window.focus();" & vbNewLine & _
" return;" & vbNewLine & _
"}" & vbNewLine & _
"-->" & vbNewLine & _
"</script>" & vbNewLine

RegisterClientScriptBlock("OpenNoteWin", jsNoteWin)

strJS = "javascript:OpenNoteWin( key);"

txtDetails.Attributes.Add("onClick", strJS)


--
MikeB


(sorry for the poorly quoted original text - Outlook Express just doesn't
work well sometimes)
=========================================
Hi there,

I can;t believe no one else has had this prob but here goes...

I add some javascript into my page and asp.net sometimes (not always) puts
the js into my page with a line break rendering it useless...


Here is my code...

Dim txtDetails As TextBox = CType(e.Item.FindControl("txtDetails"), TextBox)
'Create the javascript string

strJS
="javascript:ExtendedNotes_window=window.open('extendednotes.aspx?key=" &
key &
"','ExtendedNotes_window','scrollbars=no,width=480,height=300');ExtendedNote
s_window.focus()"

txtDetails.Attributes.Add("onClick", strJS)



Here is the source wjhen it runs.....

When it works the source code looks like (take wrapping off) - <input
name="dgrdTimeSheet:_ctl2:txtDetails" type="text" maxlength="20"
readonly="readonly" id="dgrdTimeSheet__ctl2_txtDetails" class="soft"
onClick="javascript:ExtendedNotes_window=window.open('extendednotes.aspx?key
=18C2B4EB-F8B3-462B-AB74-7307D54DBEF7','ExtendedNotes_window','scrollbars=no
,width=480,height=300');ExtendedNotes_window.focus()" style="width:80px;" />

When it doesn't - <input name="dgrdTimeSheet:_ctl2:txtDetails" type="text"
maxlength="20" readonly="readonly" id="dgrdTimeSheet__ctl2_txtDetails"
class="soft"
onClick="javascript:ExtendedNotes_window=window.open'extendednotes.aspx?key=
18C2B4EB-F8B3-462B-AB74-7307D54DBEF7
<puts line break here>
','ExtendedNotes_window','scrollbars=no,width=480,height=300');ExtendedNotes
_window.focus()" style="width:80px;" />

This obviously causes unterminated string constant. It's not the editor I
view my source in either. I saw another posting similar to mine and the guy
had checked all the characters but no one provided an answer to him.

This is really urgent. Can anyone help????

Thanks,

Sasha
 
Back
Top