473,385 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Redirecting page will open perticular webpage based on passing parameter?

Your blog is very help full,
I have one requirement like this
I have a table CUSTOMER in that CUSTID,NAME,URL columns is thier
CUSTID NAME URL
1 asp www.asp.net
2 weblog www.weblogs.asp.net
3 google www.google.com

My question is I opening perticular url based on CUSTID

I am Passing parameter Like www.Example.com?CUSTID=1 That

corressponding URL data(Ex:www.asp.net) It will open directly in browser

using asp.net........
plz help me ...........
Thank you,
anil
Sep 19 '12 #1
18 3603
There are many ways to do this... My 1st choice would be to use a GridView control. Then you set the DataSource of that gridview to be the DataTable of your Customer table.

In the design view for the grid, you can select linkbutton or the more complicated templateview (if you want more control). http://www.asp.net/web-forms/tutoria...iew-control-cs
Sep 20 '12 #2
Thank u?
I am trying already gridview I am selecting gridview transfar that value next page?

Send me your mail Id I will send my code
Any free time is their customize mt code I am asking above question
Sep 24 '12 #3
Rabbit
12,516 Expert Mod 8TB
If you have any code, please post it in the thread.
Sep 24 '12 #4
WebForm1.aspx
Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GvDept" runat="server" AutoGenerateSelectButton="True" 
  2.         onselectedindexchanging="GvDept_SelectedIndexChanging"></asp:GridView>
  3. WebForm.aspx.cs
  4. protected void Page_Load(object sender, EventArgs e)
  5.     {
  6.         SqlConnection con = new SqlConnection(
  7.             @"Data Source=<removed>;Initial Catalog=<removed>;Persist Security Info=True;User ID=<removed>;Password=<removed>");
  8.  
  9.         SqlDataAdapter da = new SqlDataAdapter("select * from redirecturl", con);
  10.  
  11.         DataSet ds = new DataSet();
  12.         da.Fill(ds, "redirecturl");
  13.         GvDept.DataSource = ds.Tables["redirecturl"];
  14.         GvDept.DataBind();
  15.         GvDept.DataKeyNames = new string[] { "customerid" };
  16.     }
  17.     protected void GvDept_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
  18.     {
  19.         GvDept.SelectedIndex = e.NewSelectedIndex;
  20.  
  21.         string Dno = GvDept.SelectedValue.ToString();
  22.  
  23.  
  24.         Response.Redirect("~/QueryStringParams2.Aspx?Dno="+Dno);
  25.  
  26.     }
  27. QueryStringParams2.Aspx
  28. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  29.  
  30. <html xmlns="http://www.w3.org/1999/xhtml">
  31. <head runat="server">
  32.     <title></title>
  33. </head>
  34. <body>
  35.     <form id="form1" runat="server">
  36.     <div>
  37.     <asp:GridView ID="GvEmp" runat="server" 
  38.         EmptyDataText="There Are No Employees In Selected Department" 
  39.             AutoGenerateColumns="false" Width="99px">
  40.         <Columns>
  41.         <asp:TemplateField HeaderText="Redirect URL">
  42.         <ItemTemplate>
  43.         <a href='<%#Eval("coupounurl") %>'><%#Eval("coupounurl")%></a>
  44.         </ItemTemplate>
  45.         </asp:TemplateField>
  46.         </Columns>
  47.         </asp:GridView>
  48.         <br />
  49.     </div>
  50.     </form>
  51. </body>
  52. </html>
  53. .cs
  54. protected void Page_Load(object sender, EventArgs e)
  55.     {
  56.         string Dno = Request.QueryString["Dno"];
  57.         //string strEmpId = Request.QueryString["strEmpId"];
  58.         SqlConnection con = new SqlConnection(
  59.             @"Data Source=<removed>;Initial Catalog=<removed>;Persist Security Info=True;User ID=<removed>;Password=<removed>");
  60.  
  61.         SqlCommand cmd = new SqlCommand("select coupounurl from redirecturl where customerid=" + Dno, con);
  62.  
  63.         con.Open();
  64.         SqlDataReader dr = cmd.ExecuteReader();
  65.         GvEmp.DataSource = dr;
  66.         GvEmp.DataBind();
  67.         con.Close();
  68. }
Sep 25 '12 #5
You may wish to censor your password...
Sep 25 '12 #6
Rabbit
12,516 Expert Mod 8TB
I have removed the sensitive information. Please use code tags when posting code.

It looks like you're already outputting a url, why would you need an additional redirect?
Sep 25 '12 #7
Thank you,
my question is I am selecting First page gridview value based on that I want to open Browser that url,
Sep 26 '12 #8
Not open next page,directly open browser,
after thatmy url look like something?CUSTID=1

After iam cheanging qs values2,3.....based on that values directly open in broser not next page
Sep 26 '12 #9
Rabbit
12,516 Expert Mod 8TB
I have no idea what you just said.
Sep 26 '12 #10
Understand my question completely
Sep 26 '12 #11
Rabbit
12,516 Expert Mod 8TB
The problem is that I don't understand what you're trying to say. Telling me to understand something doesn't help me to decipher what you're trying to say.
Sep 26 '12 #12
Understand his question completely.


Trololol
Sep 26 '12 #13
any body help me the above question
Sep 27 '12 #14
From what I gather, there is a database table somewhere that has at least 3 columns: custid, sitedesc, siteurl.

Using asp.net (of which I know nothing about), he would like to open a NEW browser with the siteurl that matches the row with a particular custid, based on a GET variable in the URL?
Sep 27 '12 #15
yes,
www.example.com/?CUSTID=1
I want to chnge CUSTID=2 based on that id corresponding siteurl data value(EX:http://bytes.com) this will open directli open in browser
Sep 28 '12 #16
Hi,I am getting result but opening new tab window browser,
Can any one help me I want to same page,after that I want to change query string value that corresponding value will open in browser plz help me any one
Oct 2 '12 #17
Default.aspx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="Gvurl" runat="server" AutoGenerateSelectButton="True" AutoGenerateColumns="false"
onselectedindexchanging="GvDept_SelectedIndexChang ing" Width="227px">
</asp:GridView>
</div>
</form>
</body>
</html>
.CS
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection( @"Data Source=<>;Initial Catalog=productdb;Persist Security Info=True;User ID=<>;Password=<>");

SqlDataAdapter da = new SqlDataAdapter("select * from redirecturl", con);

DataSet ds = new DataSet();
da.Fill(ds, "redirecturl");
Gvurl.DataSource = ds.Tables["redirecturl"];
Gvurl.DataBind();
Gvurl.DataKeyNames = new string[] { "customerid" };
}
protected void GvDept_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
Gvurl.SelectedIndex = e.NewSelectedIndex;

string Dno = Gvurl.SelectedValue.ToString();

Response.Redirect("~/QueryStringParams2.Aspx?TagId="+Dno);

}
QueryStringParams2.Aspx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GvRed" runat="server"
EmptyDataText="There Are No Employees In Selected Department"
AutoGenerateColumns="false" Width="99px">
<%--<Columns>
<asp:TemplateField HeaderText="Redirect URL">
<ItemTemplate>
<a href='<%#Eval("coupounurl") %>'><%#Eval("coupounurl")%></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>--%>
</asp:GridView>
<br />
</div>
</form>
</body>
</html>
.CS
public partial class QueryStringParams2 : System.Web.UI.Page
{

String URL = "";
protected void Page_Load(object sender, EventArgs e)
{
string Dno = Request.QueryString["TagId"];

SqlConnection con = new SqlConnection( @"Data Source=<>;Initial Catalog=productdb;Persist Security Info=True;User ID=<>;Password=<>");

SqlCommand cmd = new SqlCommand("select coupounurl from redirecturl where customerid=" + Dno, con);

con.Open();

SqlDataReader dr = cmd.ExecuteReader();
GvRed.DataSource = dr;
GvRed.DataBind();
dr.Close();

object drReader = cmd.ExecuteScalar();
if (drReader != null)
{
URL = drReader.ToString();
}

con.Close();
if (!String.IsNullOrEmpty(URL))
{

Response.Write("<script language='javascript'>window.open('" + URL + "','_newtab');</script>");

}



}
Oct 2 '12 #18
I want to open in same page display passing query string corresponding value open in browser(EX:www.google.com:TagId=1)
After that i am chnging TagId=2 it will open corresponding value(Ex:www.bytes.com) and so on..
Oct 2 '12 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Matt | last post by:
I want to write a ASP page to open/download a file In fileview.jsp, I have the file browse, and when user click submit button, fileview2.asp should open the file. fileview.asp ============...
12
by: Christoph Bergmann | last post by:
Hi... We want to write an open source web based TEXT editor and would be happy about any help ;-) Please notice: We do NOT want to write a web based WEB editor, where you can edit a web...
10
by: Tom Jenkins | last post by:
I have looked at many JavaScripts and I cannot seem to find exactly what I am looking for. It might be so simple that it went right over my head but on the other hand, I am not sure if this can be...
2
by: Khamal | last post by:
need to passing parameter from 1st page to 2nd page... try to use public static void user_param(string namaku ,string umurku ) but still cannot why?? please help... -- :: KHAMAL ::
1
by: Joe Smith | last post by:
How to pass parameter to a Vb.Net application? ..Net Framework 1.1. Thanks, Joe
1
by: anushree1631 | last post by:
hi I am working in C#.Net 2005. I want the whole code for Passing Parameter in Crystal report Please send it fast It's very urgent with regards, Anushree
4
by: abhishekbrave | last post by:
Hi Can we pass a value through hyperlink. My requirement is that suppose i have 3 hyperlinks 1 2 3 When I click on 1 or 2 or 3 another HTML page will get open having the information that "1 is...
2
by: Martin \(Martin Lee\) | last post by:
Hi, I am new in C sharp. I make a button, when users click the button, I want it to open a webpage (for example www.yahoo.com ) How to do? What should the code be? Thanks!
6
by: F159753 | last post by:
Hello, I have a form includes one text box named "Date", one Submit botton named " Add Item" which will submit the form and open other form. there is onemore button named " Add Mileage" which...
7
by: AmiMitra | last post by:
i am having problem with passing parameter through navigateUrl property of a hyperlink. in the page where i am using the hyperlink , i am getting the data thorugh commonutility. i want to pass this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.