Solved

How refresh gridview when open link to _blank target?

Posted on 2009-07-13
6
429 Views
Last Modified: 2012-05-07
ASP.NET email web app...

Gridview with inbox of emails and "View Message" template column.  All "unread" messages have yellow as the color for the gv row.  When you click on "View Message" it opens the message in a new window basically.

I would like to automatically refresh the gridview after they click on the "View Message" link.  How can I do this?

The gridview "View Message" column is defined as follows...
                <asp:TemplateField HeaderText="Msg" ItemStyle-Width="10px">
                    <ItemTemplate>
                        <asp:HyperLink ID="hlViewMsg" Target="_blank" runat="server" NavigateUrl='<%# Eval("MsgId", "autoactions.aspx?action=mark_as_read&msgid={0}") %>'
                            Text='Open' Visible='True') %>'></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>

Autoactions.aspx basically marks the db record as "read" then redirects to the message contents.  
0
Comment
Question by:RobertNZana
  • 3
  • 3
6 Comments
 
LVL 15

Expert Comment

by:spprivate
ID: 24843488
Just have a javascript function

say function mysubmit()
{

document.forms[0].submit();
}

register this event as a click event for the link
0
 
LVL 15

Expert Comment

by:spprivate
ID: 24843504
Here is a good link to handle postbacks in java script
0
 
LVL 9

Author Comment

by:RobertNZana
ID: 24844208
Can you provide an example of registering the event as a click event for the link?  Remember the link is a template field in a gridview...
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 15

Accepted Solution

by:
spprivate earned 500 total points
ID: 24853690
The example I have is for a check box in grid view.But you can do the same for link

protected void GridView1_RowDataBound(object sender,

GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

CheckBox CheckBox1 = (CheckBox)e.Row.FindControl("CheckBox1");

CheckBox1.Attributes["onclick"] = string.Format("alert({0});",

e.Row.RowIndex);

}

}

Open in new window

0
 
LVL 9

Author Comment

by:RobertNZana
ID: 24853867
I'm dont know js.  So, instead of "alert" I would call "mysubmit"?  That will refresh the page basically?  Thanks!
0
 
LVL 9

Author Comment

by:RobertNZana
ID: 24854032
I ended up doing this...

            Dim l As HyperLink = CType(e.Row.FindControl("hlViewFile"), HyperLink)
            l.Attributes.Add("onClick", "window.location.reload()")

Since you started the good ideas flowing i will credit u.  Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now