By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,899 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,899 IT Pros & Developers. It's quick & easy.

Hidden control problem

P: n/a
Hello!

I am working with 2 webforms. The first webform has a 2 weborm textboxes
that I use as a placeholders. The second webform is a popup window that has a
DataGrid in it. The DataGrid has 2 columns (Vendor Name and Vendor No.) When
the user clicks at a Datagird cell, the Vendor Name and Vendor No. are passed
to the first webform's 2 textboxes. But only the Vendor Name should be
visible. I therefore changed the Vendor No. textbox's Visible property to
False. But now the Vendor No. is no longer being retrieved by the first
webform. Should I use a different control? Suggestions? Thanks in advance.
Below is the code for the second webform (popup window):

public void DataGridEventHandler( object sender, DataGridCommandEventArgs e)
{
if (e.CommandName == "Select_Vendor_No" || e.CommandName
"Select_Vendor_Name")
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';opener.document.Form1.txtVend orNo.value='"+vendorNo+"';window.close();";
}
}

private void DataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';
opener.document.Form1.txtVendorNo.value='"+vendorN o+"'; window.close();";
LinkButton lnk;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.Item)
{
lnk = (LinkButton)e.Item.FindControl("lnkBut");
lnk.Attributes.Add("onclick", script);
}
}

Below is the code for the first webform:

private void btnSearch_Click(object sender, System.EventArgs e)
{
string vendorName = txtVendorName.Text;
string vendorNo = txtVendorNo.Text;
.........
}

Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You don't show how you are setting the visible property to false but I am
going to assume you're doing it in your code behind. When you set visible
to false in code behind, the control isn't rendered to the HTML page.

To make your Vender No textbox not visible but still have it contain a
value, do it like this:

txtVendorNo.Style["DISPLAY"] = "none";

then to display it again:

txtVendorNo.Style["DISPLAY"] = "block";

or

txtVendorNo.Style.Remove("DISPLAY");

HTH

DalePres
MCAD, MCDBA, MCSE
"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...
Hello!

I am working with 2 webforms. The first webform has a 2 weborm textboxes
that I use as a placeholders. The second webform is a popup window that
has a
DataGrid in it. The DataGrid has 2 columns (Vendor Name and Vendor No.)
When
the user clicks at a Datagird cell, the Vendor Name and Vendor No. are
passed
to the first webform's 2 textboxes. But only the Vendor Name should be
visible. I therefore changed the Vendor No. textbox's Visible property to
False. But now the Vendor No. is no longer being retrieved by the first
webform. Should I use a different control? Suggestions? Thanks in advance.
Below is the code for the second webform (popup window):

public void DataGridEventHandler( object sender, DataGridCommandEventArgs
e)
{
if (e.CommandName == "Select_Vendor_No" || e.CommandName
"Select_Vendor_Name")
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';opener.document.Form1.txtVend orNo.value='"+vendorNo+"';window.close();";
}
}

private void DataGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string vendorName = e.Item.Cells[1].Text;
string vendorNo = e.Item.Cells[3].Text;
vendorName = vendorName.Replace("'","\'");
string script =
"javascript:opener.document.Form1.txtVendorName.va lue='"+vendorName+"';
opener.document.Form1.txtVendorNo.value='"+vendorN o+"'; window.close();";
LinkButton lnk;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType ==
ListItemType.Item)
{
lnk = (LinkButton)e.Item.FindControl("lnkBut");
lnk.Attributes.Add("onclick", script);
}
}

Below is the code for the first webform:

private void btnSearch_Click(object sender, System.EventArgs e)
{
string vendorName = txtVendorName.Text;
string vendorNo = txtVendorNo.Text;
.........
}

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.