I'm getting an error :
Error 1 'System.Web.UI.ScriptManager' does not contain a definition for 'RegisterClientSciptBlock'
on this line
ScriptManager.RegisterClientSciptBlock
thanks,
I'm getting an error :
Error 1 'System.Web.UI.ScriptManager' does not contain a definition for 'RegisterClientSciptBlock'
on this line
ScriptManager.RegisterClientSciptBlock
thanks,
I am trying to pass a value from a pop up window back to the parent page. The query string is successful, but it wont go back to the previous page, but instead the pop-up window will redirect to the previous page with the values. What I want to do is close the pop-up window, and go back to the previous page with the values. Here are the code that I currently have: //this is action performed when the button to submit the values are clicked
protected void btnSelect_Click(object sender, EventArgs e)
{
GridViewRow row = grdAll.Rows[SelectedProductIndex];
name = row.Cells\[2\].Text.ToString();
Industry = row.Cells\[3\].Text.ToString();
SubInd = row.Cells\[4\].Text.ToString() ;
geo = row.Cells\[5\].Text.ToString();
location = row.Cells\[6\].Text.ToString();
Page.Response.Redirect("frmMain.aspx?name=" + name + "&industry=" + Industry + "&subInd=" + SubInd + "&geo=" + geo + "&location=" + location);
}
//this is the page_load of the parent window
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Page.Request.QueryString["name"] != null)
{
txtMPSname.Text = Page.Request.QueryString["name"].ToString();
txtLoc.Text = Page.Request.QueryString["location"].ToString();
DlstGeo.Text = Page.Request.QueryString["geo"].ToString();
DlstInd.Text = Page.Request.QueryString["industry"].ToString();
DlstSubInd.Text = Page.Request.QueryString["subInd"].ToString();
}
}
}
Thanks so much! problem solved!
Thanks for the reply. I tried using literal, but I am getting an error
Quote:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
in this line
output.Text = string.Format(@"<input id=""RowIndex{0}"" type=""radio"" name=""radSelect"" value=""{0}"" checked=""checked"" />");
Hi, I have included a radiobutton on a gridview using HTML control. I tried getting the index of the row selected by the radio button, but I can't figure out how. I tried using the Request.Form["RadiobuttonName"] but it gives me the value on the cell not the row index. Here is the code When I click the button to retrieve the value.
protected void btnSelect_Click(object sender, EventArgs e)
{
string selectedValue = Request.Form["radSelect"];
int index = Convert.ToInt32(Request.Form["radSelect"]);
}
And here is .aspx page
<asp:GridView ID="grdAll" runat="server" OnRowCommand="MPS_Selected" AutoGenerateColumns="false" OnRowDataBound = "grd_rowdatabound">
<Columns>
<asp:BoundField DataField="ID" HeaderText = "" Visible="false" />
<asp:BoundField DataField="Name" HeaderText = "MPS Account Name" />
<asp:BoundField DataField="Industry" HeaderText = "Industry" />
<asp:BoundField DataField="SubIndustry" HeaderText = "Sub-Industry" />
<asp:BoundField DataField="Geo" HeaderText = "Geo" />
<asp:BoundField DataField="LocType" HeaderText = "Location" />
<%--<asp:buttonfield buttontype="Button" commandname="Select" headertext="" text="Select"/>--%>
<asp:TemplateField HeaderText="Select One">
<ItemTemplate>
<input id="rdSelect" name= "radSelect" type="radio" value='<%# Eval("ID") %>' />
<%--<asp:RadioButton ID = "rdSelect" runat="server" onclick = "RadioCheck(this)" />
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("ID")%>' />--%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Any help will do. Thanks!
what should I put on the 'msg!'? when the place this code on the method it only pop's up msg on the messagebox. Thanks!
Yes, I placed some breakpoints, but when I click on the button where it will pop-up a window it won't stop on the breakpoint..here is the code for the pop-up window and the code for the passing back the value from the gridview to the parent page. //code for pop-up window
protected void btnAll_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>");
sb.Append("window.open('frmList.aspx', 'MPS Account List',");
sb.Append("'top=0, left=0, width='500', height='700', menubar=no,toolbar=yes,status,resizable=yes,addressbar=yes');<");
sb.Append("/script>");
Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
ClientScript.RegisterClientScriptBlock(t, "PopupScript", sb.ToString());
}
//code for passing value back
public void MPS_Selected(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script type='text/javascript'>alert('msg!')</script>");
// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);
//Populate textbox with selected values
//String s = Request.QueryString\["grdAll.Rows\[index\].Cells\[1\].Text.ToString();"\];
string name = grdAll.Rows\[index\].Cells\[1\].Text.ToString();
string Industry = grdAll.Rows\[index\].Cells\[2\].Text.ToString();
string SubInd = grdAll.Rows\[index\].Cells\[3\].Text.ToString();
string geo = grdAll.Rows\[index\].Cells\[4\].Text.ToString();
string location = grdAll.Rows\[index\].Cells\[5\].Text.ToString();
Page.Response.Redirect("~/WebForm1.aspx?name=" + name + "&industry=" + Industry + "&subind=" + SubInd + "&geo=" + geo + "&location=" + location);
//HttpContext \_context = HttpContext.Current;
//\_context.Items.Add("name", na
This is the method that I use to show a new window, I'm not sure what is wrong but it won't work anymore
protected void btnAll_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>");
sb.Append("window.open('frmList.aspx', 'MPS Account List',");
sb.Append("'top=0, left=0, width='500', height='700', menubar=no,toolbar=yes,status,resizable=yes,addressbar=yes');<");
sb.Append("/script>");
Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
ClientScript.RegisterClientScriptBlock(t, "PopupScript", sb.ToString());
}
Hi, Where do I do that in the file? Sorry for the questions, I am very new to this. I just started a week ago. And I am stuck on finding a way of passing back a value from a page to it's parent page. Thanks,
It's in the root of the site. I'm not sure where the problem is, since when I run the debug it does not go anywhere when I click the button in the GridView. Here is the ASP code of the GridView at frmList.aspx
<asp:GridView ID="grdAll" runat="server" OnRowCommand="MPS_Selected" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="ID" HeaderText = "" Visible="false" />
<asp:BoundField DataField="Name" HeaderText = "MPS Account Name" />
<asp:BoundField DataField="Industry" HeaderText = "Industry" />
<asp:BoundField DataField="SubIndustry" HeaderText = "Sub-Industry" />
<asp:BoundField DataField="Geo" HeaderText = "Geo" />
<asp:BoundField DataField="LocType" HeaderText = "Location" />
<asp:buttonfield buttontype="Button" commandname="Select" headertext="" text="Select"/>
</Columns>
</asp:GridView>
They are located on the same path. The WebForm1.aspx is the start page and serves as the parent. The frmList.aspx is a pop-up window. Basically what should happen is the frmList.aspx will call back the WebForm1.aspx and pass the values to the controls of WebForm1.aspx. Thanks,
I tried your suggestions but, this time everytime I click the select button it still gives me the same error. Here is the code behind from the WebForm1.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
namespace AccoutMgt
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page\_Load(object sender, EventArgs e)
{
if (Page.Request.QueryString\["name"\] != null)
{
txtMPSname.Text = Page.Request.QueryString\["name"\];
txtLoc.Text = Page.Request.QueryString\["location"\];
DlstGeo.DataValueField = Page.Request.QueryString\["geo"\];
}
}
protected void BtnSearch\_Click(object sender, EventArgs e)
{
}
}
}
and here is the code from frmList.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
namespace AccoutMgt
{
public partial class List : System.Web.UI.Page
{
//public static string connStr = "SERVER=157.184.82.187;DATABASE=acctinformation;UID=root;PASSWORD=l3xmark;pooling=false;";
//public static MySqlConnection mycon;
//ClassProj cs1 = new ClassProj();
protected void Page\_Load(object sender, EventArgs e)
{
if (ClassProj.GetDBconn() == true)
{
if (!IsPostBack)
{
String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
MySqlDataReader reader = cmd.ExecuteReader();
//Bind the grid view
grdAll.DataSource = reader;
grdAll.DataBind();
reader.Close();
cmd.Dispose();
}
}
ClassProj.CloseConn();
}
public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
// C
Thanks!I will try those changes. I am not sure what Page.IsPostBack() but I will do a research on that. Thanks!
Hi, I am new in ASP.NET c# web application development. I am creating a simple Account Management application. I am experiencing an error when using QueryString to pass value to a form. I have a main form named WebForm1.aspx. When I click a button named View List, it will pop-up a separate window with a gridview displaying all the account from a SQL database. The new window is called frmList.aspx, the gridview has a button on each row, and when I click the button it should transfer the data from the row to several textbox in the first page, WebForm1.aspx. But after I click the button it gives me an error. Below is the code behind for frmList.aspx
protected void Page_Load(object sender, EventArgs e)
{
if (ClassProj.GetDBconn() == true)
{
String SQLstr = "SELECT a.ID, a.NAME AS Name,b.NAME AS Industry,a.subindustry as SubIndustry,a.geo AS Geo,c.NAME AS LocType FROM mpsacct AS a,industry AS b,location AS c WHERE a.industry=b.id AND a.loctype=c.id";
MySqlCommand cmd = new MySqlCommand(SQLstr, ClassProj.mycon);
MySqlDataReader reader = cmd.ExecuteReader();
//Bind the grid view
grdAll.DataSource = reader;
grdAll.DataBind();
reader.Close();
cmd.Dispose();
}
ClassProj.CloseConn();
}
public void MPS\_Selected(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Select")
{
// Convert the row index stored in the CommandArgument
// property to an Integer.
int index = Convert.ToInt32(e.CommandArgument);
//Populate textbox with selected values
//String s = Request.QueryString\["grdAll.Rows\[index\].Cells\[1\].Text.ToString();"\];
string name = grdAll.Rows\[index\].Cells\[1\].Text.ToString();
string Industry = grdAll.Rows\[index\].Cells\[2\].Text.ToString();
string SubInd = grdAll.Rows\[index\].Cells\[3\].Text.ToString();
string geo = grdAll.Rows\[index\].Cells\[4\].Text.ToString();
string location = grdAll.Rows\[index\].Cells\[5\].Text.ToString();
Page.Response.Redirect("WebForm1.aspx?name=" + name + "&industry=" + Industry + "&subind=" + SubInd + "&geo=" + geo + "&location=" + location);
}
}