IDE Sucks - Workaround?

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

I've searched, read and tried everything until I'm finally frustrated.
Apparently this is a known IDE weakness, and I _CANT_ seem to get around
it...

My problem is working with this line:
<A
HREF="javascript:popUp('EventLogView.aspx?ID=<%#DataBinder.Eval(Container.Da
taItem,"ID")%>')">View</A>

The code compiles and runs fine, however when trying to switch from HTML
back to design view, I get the following IDE error:

Could not open in design view. Quote values differently inside a
'<%..."value"...%>' block.

Nothing I do gets me back to design view except removing the line.
Everything I read advised to replace double quotes with single quotes, but
I've tried every combination I can think of and it either won't compile, I
get a runtime 'badly formed' error, or the same condition where I can't get
into design view.

Please any help? Any other crafty way to make a javascript function fire
from HREF?
 
actually, there is a way... put an empty Anchor tag on your form in the
designer and then just
programatically replace the href attribute to be what it needs to be in the
page's PreRender
event.
 
I've tried to do my own research, but I haven't been able to make this
work...

Did you mean to add a placeholder and then add an anchor tag to the
placeholder's controls programatically? I couldn't find a way to directly
add an anchor control in the designer but MSDN referenced this method, so I
was working to make it work.

Assuming this is correct (?) I added a placeholder (and several other
controls for that matter) into the template for the column in my datagrid.
The problem here, is that I can't find how to programatically access that
control then using the standard method (there isn't a control created in the
class to reference) to add the HtmlAnchor control to it...

....what am I missing?
 
to programmatically access a simple HTML control requires you to right-click
on the
HTML control (i.e. anchor) then select Run As Server Control. You will now
be able
to refer to this control programatically by its ID property.
 
I know about the runat=server, but controls inside a datagrid template are
different. They have the runat=server parameter, but they are not directly
accesible in code. Try it, I promise!
 
I have an <asp:button> inside of an <asp:datagrid> whose properties are
being modified successfully so you
can probably adapt this to what you are trying to do....

Here's my column:

<asp:TemplateColumn>
<ItemTemplate>
<asp:Button Text="Log" CommandName = "ViewLog" Runat="server"
CommandArgument='<%#
((BatchServer.ReportJobInfo)Container.DataItem).correspond_id %>'
OnCommand="ViewReport_Click" enabled='<%# logEnabled(
((BatchServer.ReportJobInfo)Container.DataItem).logexists ) %>'/>
</ItemTemplate>
</asp:TemplateColumn>

Here's the code for the button's OnCommand handler:

protected void ViewReport_Click(object source, CommandEventArgs e)
{
if ( e.CommandName.Substring(4,3) == "Log" )
{
Response.Redirect("Log.aspx?db=" + lstDatabases.SelectedItem.Text.Trim()
+
"&job=" + e.CommandArgument);
}
else
{
string strArgument = e.CommandArgument.ToString().Substring(3);
string strType = e.CommandArgument.ToString().Substring(0,3);

string str =
lstReportPaths.Items[lstDatabases.SelectedIndex].Text.Trim();

if ( strType == "CRY" )
Response.Redirect("CrystalInfo.aspx?rpt=" + str + strArgument);
else
Response.Redirect("BatchInfo.aspx?dir=" + str + "&rpt=" + strArgument);
}
}
 
You can access them in code, but they aren't created right away - you'll
have to trap the itemcreated or itemdatabound events, then use "
e.Item.FindControl( "controlName") " to get at the control. Once you do
this, working with the items is very easy.
 
Back
Top