Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Thursday, March 29, 2012

Pop Ups

Hi

I am using a popup, I launch the popup from a form, the user then choses an item on the popup, which is put into a session variable and then another form is launched. This works OK except the original form which launched the popup is still open how do I close it when the popup is launch. I use the code below to launch the popup

Dim sTempAsString

sTemp = "<script>window.open('LPopUpContractor.aspx',null,'top=150,left=250,height=150,width=450,status=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=no');</script>"

Response.Write(sTemp)

Response.Flush()

Thanks

Louisa

Hi,
you can close the form from its container window,
<!-- Put this script in MyMainForm.aspx -->
<script type="text/javascript">
window.open('myPopupForm.aspx');
window.close();
</script>

or let the popup close the window that launched it,
<!-- Put this script in myPopupForm.aspx -->
<script type="text/javascript">
if(window.opener) {
window.opener.close();
}
</script>

This works brillantly, but I now get a popup before mine saying:

The Web page you are viewing is trying to close the window

Do you want to close this window?

I click on the yes and my popup appears, how do I get rid of the error msg popup?

Thanks

Louisa


Hi,
it is not an error message popup, it is an Internet Explorer security setting that prevents a script to close a window that wasn't opened by the script itself, without the user permission... well, it seems that a workaround exists for Internet Explorer, just try to set the window.opener property to some value. For example
<script type="text/javascript">
window.opener = this;
window.open('myPopup.aspx');
window.close();
</script>

but I'm not sure it will work on all browsers.


Hi,

The above doesn't seem to work for me as it just puts the pages into a loop, can I not close a previous page from the page load of the new page, when the new page is fully loaded?

Thanks

Louisa


Hi,
I don't know if a workaround exists for the security popup. Try to post this question in theClient Side Web Develoment section of these forums.

a little discussion about that same pop-up

http://forums.asp.net/962609/ShowPost.aspx


Hi,
thanks for posting the link, onewisehobbit.

pop ups not working

Hi

i am working on a project which involves pop up windows to enter information which worked fine at uni

i brought the exact same project home and the popups dont 'popup, nothing happens

i've allowed popups in internet explorer, but they still dont work

is there something else i've overlooked??

cheers!!

hehe

sorry for wasting space

just remembered i took a line of code out just before i left uni yesterday that stopped popups working

blah!!

Saturday, March 24, 2012

Populate fields

Hi:

I am looking for lookup table ability so the user will not have re-enter student information data. I have a table called for example "StudentInfo" - lookup table and another table called StudentActivity. My environment is VS.net/SQL/C#

I would like to have a form that would allow user to to select specific student (eg. from the drop down or listbox from StudentInfo table) and populate StudentActivity table based fields with the values from StudentInfo table, based on user selection.

ENTRY FORM (bound to StudentActivityTable)

Select Student: drop down menu (from StudentInfo)

Student name (populated from StudentInfo)

Student age (populated from StudentInfo)

Student address (populated from StudentInfo_

Location (user input)

Date: (user input) etc.

I would appreciate your assistance.

Danka

You need to get to grips with the basics of data access. http://quickstarts.asp.net/QuickStartv20/aspnet/doc/data/default.aspx

Here is a tutorial that is doing something like what you describe. It pairs a DropDownList with a DetailsView: http://msdn2.microsoft.com/en-us/library/aa581790.aspx

The DetailsView displays individual records, and can be used to edit or delete them. If the DetailsView control doesn't give you what you want, you could try the FormView control. I think the FormView offers greater flexibility in formatting the appearance.

Hope this helps


Yes, this is a good introduction for me. Thanks.


Hi:

I implemented it as a find compnay feature that provides user with a view of detailed company information based on the company selection in the drop down list.

Regarding my previous question related to drop down selection I tried the following code on someones advise. When user selects a value from the pull down menu this code updates templated field which is bound to database field. In the insert template I made this control not visible. I probably could implement the same on the edit template. It should be a better way than this. I am all new to it so I would appreaciate your thoughts.

} protectedvoid DropDownList1_SelectedIndexChanged(object sender,EventArgs e) { TextBox txtName = (TextBox)DetailsView1.FindControl("txtInsertLegalCompanyName"); DropDownList ddlName = (DropDownList)DetailsView1.FindControl("DropDownList1"); txtName.Text = ddlName.SelectedValue;

Now, I also have radio buttons list with two values Yes and No (true and false). I need some piece of code that would allow to show the selected value on the edit template (yes or no). Check box list allow to select both values True and False so I probably need some piece of code here so if one is selected the other one is deselected. I would also like to dispay Yes instead true, in vb I would use IIF... statment...

Your help would be appreaciated.

Populate Month in Combobox <Resolved>

Hi!

I have a asp.net control combo box. I want to pouplate it with the name of the months.

I am wring the code in the code behind. I am using vb.net as the code behind.

My code is

'Month
dim i as integer
dim myvar as string

i = 1
Do While i <= 12
myvar = MonthName(i, True)
cboMonth.Items.Add(myvar)
i = i + 1
Loop

I get the populated month names in the combobox, because of the function month name.

But in the value I want 1,2,3 not Jan, Feb, Mar...How to achive this.

Had been it ASP I wud have written:

do while iLoop <= 12
myvar = MonthName(iLoop,true)
Response.Write "<option value=" & iLoop & " selected>" & myvar & "</option>"
iLoop = i Loop+1
loop
This wud have given me the dsired result.

How to do in VB.NET?With a bit of R&D got the solution:

i = 1
Do While i <= 12
myvar = MonthName(i, True)
cboToMonth.Items.Add(New ListItem(myvar, i))
i = i + 1
Loop

populate one dropdownlist based on the selected of another dropdownlist

hi
i am using c# asp.net
i have one datagrid in my form and i bound two dropdown list using coding. i loaded my database values in my first dropdown list by using this code:

private void Page_Load(object sender, System.EventArgs e)
{// Put user code to initialize the page here
if(!Page.IsPostBack)
{ BindData();
PopulateList();
}
}
public void BindData()
{
SqlDataAdapter ad = new SqlDataAdapter("SELECT Course_NAME FROM JTSISControlManager_Course",conn);
DataSet ds = new DataSet();
ad.Fill(ds,"JTSISControlManager_Course");
DataGrid2.DataSource = ds;
DataGrid2.DataBind();

}
public DataSet PopulateList()
{

SqlDataAdapter ad = new
SqlDataAdapter("SELECT Course_Name FROM JTSISControlManager_Course", conn);

DataSet ds = new DataSet();
ad.Fill(ds,"JTSISControlManager_Course");
return ds;
}

here is the html coding:

<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid2" style="Z-INDEX: 101; LEFT: 328px; POSITION: absolute; TOP: 64px"
runat="server" Width="408px" AutoGenerateColumns="False" DataKeyField="Course_NAME">
<Columns>
<asp:BoundColumn DataField="Course_NAME" HeaderText="Course_NAME" />
<asp:TemplateColumn>
<HeaderTemplate>
<aspropDownList ID="Dropdownlist1" Runat="server" DataTextField="Course_NAME" OnSelectedIndexChanged ="DropDown_SelectedIndexChanged" DataSource =" <%#PopulateList()%> " AutoPostBack="True" />
<aspropDownList ID="Dropdownlist3" Runat="server" DataTextField="Dept_NAME" AutoPostBack="True" />
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></form>

then using the following code i retreived my first dropdownlist value

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender;
li=list.SelectedValue.Trim();
Response.Write(li);

}

my need is i want to use the retreived value of the first dropdownlist in query and fill the values in my second dropdownlist of the datagrid.
tell me how to use that retreived value of first dropdown list in next qurey and how to fill the second dropdownlist .so please help me to do this. give example coding to do my requirement
Edit/Delete MessageHi karthikeyan,

In my application I've Make and Model dropdowns. Model dropdown gets populated as soon as we select a make in a dropdown, it gets all the models for that make;

Here is my code;

Populating Model Dropdown
private void ddlMake_SelectedIndexChanged(object sender, System.EventArgs e)
{
if (ddlMake.SelectedValue != "")
{
PopulateFieldsInDropDowns("SELECT cat.DisplayText Model, to_char(cat.CATEGORYID) ModelID FROM TDCATEGORIES cat WHERE cat.CATEGORYLEVEL=4 and parentid= " + ddlMake.SelectedValue + " ORDER BY cat.DisplayText", ddlModel);
}
else
ddlModel.Items.Clear();
}

Populate Method
private void PopulateFieldsInDropDowns(string sqlQuery, DropDownList drpList)
{
try {
conn.Open();
OleDbCommand cmCommand = new OleDbCommand(sqlQuery, conn);
OleDbDataReader dreader = cmCommand.ExecuteReader();

drpList.Items.Clear();
drpList.Items.Add(new ListItem("", ""));

while (dreader.Read())
{
drpList.Items.Add(new ListItem(dreader.GetString(0), dreader.GetString(1)));
}

dreader.Close();

if (dreader != null)
dreader = null;

if (cmCommand != null)
cmCommand.Dispose();
}
catch
{
drpList.Items.Clear();
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "Cannot Get Data: Cannot Get Required Data.";
}
conn.Close();
}

It should rock.

thanks,
hi ahmarshi,

i tried which u given, but i got error:
System.NullReferenceException: Object reference not set to an instance of an object.

my first dropdown name is DropDownList1 and second name is ddlmodel
i modified my coding like this:
protected void DropDown_SelectedIndexChanged(object sender, System.EventArgs e)
{
DropDownList list = (DropDownList)sender;
li=list.SelectedValue.Trim();
Response.Write(li);

if (li != "")
{
PopulateFieldsInDropDowns("SELECT Dept_NAME from JTSISControlManager_Department where Course_ID in (select Course_ID from JTSISControlManager_Course where Course_NAME= '" + li + "')", ddlmodel);
}
else
ddlmodel.Items.Clear();
}
private void PopulateFieldsInDropDowns(string sqlQuery, DropDownList drpList)
{
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(sqlQuery, conn);
SqlDataReader dreader =cmd.ExecuteReader();


drpList.Items.Clear();
drpList.Items.Add(new ListItem("", ""));

while (dreader.Read())
{
drpList.Items.Add(new ListItem(dreader.GetString(0), dreader.GetString(1)));
}

dreader.Close();

if (dreader != null)
dreader = null;

if (cmd!= null)
cmd.Dispose();
}
catch
{
drpList.Items.Clear();
//lblMessage.ForeColor = System.Drawing.Color.Red;
Response.Write ( "Cannot Get Data: Cannot Get Required Data.");
}
conn.Close();
}

i kept break point and run this but while comming to
this line
private void PopulateFieldsInDropDowns(string sqlQuery, System.Web.UI.WebControls.DropDownList drpList)
in the drplist comes <undefined value>.
then after comming to this line
drpList.Items.Add(new ListItem("", ""));
it automatically goes to catch.please tell me and give sugestion to rectify this prooblem.

Friday, March 16, 2012

Populating a List Box

Hi

I am trying to populate a list box with all my themes that i have created but I keep getting an message which is

Type DirectoryInfo is not defined i m guessing i have to declare if but i dont know how are where please could you guys help. Thanks

1Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)23If (Not Page.IsPostBack)Then45 Dim themeDirAs New DirectoryInfo(Server.MapPath("App_Themes"))6 lstThemes.DataTextField ="Name"7 lstThemes.DataSource = themeDir.GetDirectories()8 lstThemes.DataBind()910End If1112 End Sub13

The DirectoryInfo class is located under the System.IO namespace.


Yeah i tired declaring it as Inherits System.IO. Is that the correct appraoch


hello i ve tried to use the system io like u suggested but i still have the same problem here s my code. Do u have any ideas where i am going wrong cheers

PartialClass _Default

Inherits System.Web.UI.Page

Inherits System.IO

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)

If (Not Page.IsPostBack)Then

Dim themeDirAsNew DirectoryInfo(Server.MapPath("App_Themes"))

lstThemes.DataTextField ="Name"

lstThemes.DataSource = themeDir.GetDirectories()

lstThemes.DataBind()

EndIf

EndSub

EndClass


Is your App_Thems directory in your web directory? I would check the path returned by Server.MapPath("App_Theme"), perhaps it doesn't exists and that's why you're getting an error.

bigyawn_hippo:

hello i ve tried to use the system io like u suggested but i still have the same problem here s my code. Do u have any ideas where i am going wrong cheers

PartialClass _DefaultInherits System.Web.UI.Page

Inherits System.IO

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)

If (Not Page.IsPostBack)Then

Dim themeDirAsNew DirectoryInfo(Server.MapPath("App_Themes"))

lstThemes.DataTextField ="Name"

lstThemes.DataSource = themeDir.GetDirectories()

lstThemes.DataBind()

EndIf

EndSub

EndClass

Hi,

Based on my understanding, you want to import the System.IO namespace in your asp.net VB application. If I have misunderstood you, please feel free to let me know.

The DirectoryInfo class is in the System.IO. If we want to use it, we can import it. For example:

Imports System.IOPartialClass _DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)If (Not Page.IsPostBack)Then Dim themeDirAs New DirectoryInfo(Server.MapPath("App_Themes")) lstThemes.DataTextField ="Name" lstThemes.DataSource = themeDir.GetDirectories() lstThemes.DataBind()End If End SubEnd Class

Alternatively, we can use this namespace in the code behind directly, for example:

Dim themeDir As NewSystem.IO.DirectoryInfo(Server.MapPath("App_Themes"))

Besides, you can find more information about asp.net by the following link:http://www.asp.net/get-started/.


I hope this helps.


Hi hyppo,

why don't you try to put only this two instructions ?

lstThemes.DataSource = themeDir.GetDirectories()
lstThemes.DataBind()

I found my code doing the same and i didn' t write ...DataTextField