Solved

How refresh gridview when open link to _blank target?

Posted on 2009-07-13
6
455 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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