Solved

How refresh gridview when open link to _blank target?

Posted on 2009-07-13
6
444 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Data is not showing from images 15 47
Connection String 16 54
SQL Login 17 48
Where can I ask about my ASP.NET MVC project? 6 35
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

18 Experts available now in Live!

Get 1:1 Help Now