Solved

How refresh gridview when open link to _blank target?

Posted on 2009-07-13
6
437 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.Net Session State alternatives 3 57
c# regex: extract & replace text between braces 6 43
ADO.NET ENTITY DATA MODEL 3 30
Not showing page correctly 3 29
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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 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

11 Experts available now in Live!

Get 1:1 Help Now