473,378 Members | 1,621 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,378 software developers and data experts.

C# Asp.net

Hi, I want to create a web form, dynamically- I mean not to add it via "Add Item", but through the code behind in the cs, and then to open it seperately like a new page.
i have tried to create it like a control - form=new form() and etc... but it doesn't work.

Can anyone help me please?
Thanks
Oct 23 '07 #1
14 1309
Plater
7,872 Expert 4TB
You could create html on the fly and show it, but I don't believe you can create aspx pages on the fly.
Since they have to have their backend compiled and that would make for self modifying code.
Maybe there is a way, but it seems like a bad practice to do so.
Oct 23 '07 #2
Thanks for the answer.
Oct 23 '07 #3
Sorry to ditrub you but I have got another quetion;
if I create a new object of htmlform like : htmlform f=new htmlform;
and I want it to open in a new page I mean other browser you in a new window, how should I do it? I tried the onclientClick="open('"+f+"')"; but it opened in the same page, not in a seperate as i wished, and I have also tried the onclient click="window.open('"+f+"')"; and it told me that the page couldn't be find - because it's not in the solution explorer... so how can i manage to open it in a seperate page?
thanks for the help , i really apriciate it
Oct 23 '07 #4
Plater
7,872 Expert 4TB
window.open() in javascript I believe is the only way to open a new browser window.
You could make a special .aspx page in your solution, that takes arguments passed to it (somehow) that will generate that page that you wanted.
Oct 23 '07 #5
alright, but can i make it dynamically via the codebehind? because I want to make a foreach to create 400 new forms and to "add" them to the solution explorer . can I add the form to the solution explorer without going to the add item etc but only by the codebehind?
Oct 23 '07 #6
Plater
7,872 Expert 4TB
Uhhh, why exactly do you need 400 forms?
What I ment was you add ONE page to your explorer, then you programattically tell that one what to display and what it looks like and stuff.
That way your javasrcript can reference it with window.open()
Oct 23 '07 #7
aa arlight i got it . and one more question,
how to transfer the parametrs to that page - it's an aspx, I can't create an instance of it in other pages right?(if I need it in Default 3 for example i can't create default4 f=new default4(); right?)
Oct 23 '07 #8
Plater
7,872 Expert 4TB
right.
you can either have the static propertes that you can set from anywhere, and that special page reads them when it loads and displays data accordingly
OR
you can try and have javascript pass them in as querystring and your special page looks at the querystring and understands what to do from there.
Oct 23 '07 #9
ok, well I don't have any idea what it means actually, so can you give just one simple example pleeaasse? of using one or both of the ways you have suggested?
Oct 23 '07 #10
Plater
7,872 Expert 4TB
For a javascript something like:
window.open("myspecialpage.aspx?title=fred likes fish&body=this goes in the body");

Then in "mysepcialpage.aspx" you look for the "title" and "body" parts of the query string and do with them as you will.


For a static page, create a static class (or module i think for vb.net....stupid vb...)
And give it like a public static string TITLE and one for BODY or something.
then in myspecialpage.aspx, you look at the values in that static class and do something with them.




You could also store information in the Session[] object and use it accross pages.
Oct 23 '07 #11
alright, everything is clear now, THANKS, you have really helped me, god bless you.
Oct 23 '07 #12
when the window.open('default.aspx') is comitted everything in the original page is erased, can I prevent it; how?
Oct 23 '07 #13
Plater
7,872 Expert 4TB
window.open() should not have any effect on the page it's being called on.
Oct 24 '07 #14
hi , look I have dynamically created a few image buttons(with a 'for') and i want that while runtime, when the user presses a specific button, to open a new page in which there would be the same image with the same ImageURL I mean, how can I add an event or something , I don't know... I mean I want to activate a method when the client presses the image button - how, this one problem, the next one is that all that happens in class and in a 'for'(see the code below), so I want that in each page opening as you said, to transfer the proper parametrs, I think the best way is thorgh a session but the problem is that there is the for loop, so it creates many sessions and when I transfer the session to the new page I can't tell it which session to use...
by the way that's why i preffered to create an specific new aspx to each imagebutton (if you remember the 400 forms that i told you...)


public ImageButton Introduction(Panel p1,System.Web.UI.WebControls.ImageButton img,DataList dl, DataList DataList1,DataSet myDS,HtmlForm Form1,SqlDataSource SqlDataSource2)
{
string JewelName=this.GetJewelName(myDS,Num);


p1 = new Panel();
p1.Style["Position"] = "Absolute";
p1.Style["Top"] = "" + Top + "px";
p1.Style["Height"] = "" + Height + "px";
p1.Style["Width"] = "" + Width + "px";
p1.BackColor = Color.Gold;
Form1.Controls.Add(p1);

img = new System.Web.UI.WebControls.ImageButton();
img.ID="img_'"+JewelName+"'";
img.Style["Position"] = "Absolute";
img.Style["Left"]= ""+100+"px";

img.ImageUrl = GetImageURLString(JewelName);

img.Style["Top"] = "" + (Top + 100) + "px";
img.Style["Height"] = "180px";
img.Style["Width"] = "180px";
Form1.Controls.Add(img);



Label l1 = new Label();
l1.Style["Position"] = "Absolute";
l1.Style["Top"] = "" + (Top + 50) + "px";
l1.Style["Left"] = "" + Left + "px";
l1.Text = myDS.Tables[0].Rows[Num][1].ToString();
Form1.Controls.Add(l1);

SqlDataSource2.SelectCommand = "SELECT [Jewel_Name], [Jewel_Commercial_Code], [Size], [Price], [Stock], [Jewel_Sub_Type_ID], [Jewel_Extra_Info] FROM [TBL_Jewel_Name] WHERE ([Jewel_Name] = ('"+l1.Text+"'))";

dl = new DataList();
dl.Style["Position"] = "Absolute";
dl.Style["Top"] = "" + (Top + 100) + "px";
dl.Style["Left"] = "" + Left + "px";
dl.DataSourceID = SqlDataSource2.ID;
dl.ItemTemplate = DataList1.ItemTemplate;
Form1.Controls.Add(dl);


ImageButton BtnImg_AddToCart = new ImageButton();
BtnImg_AddToCart.ImageUrl = "~/Photo Jewellery/add_to_cart_button[1].gif";
BtnImg_AddToCart.Style["Position"] = "Absolute";
BtnImg_AddToCart.Style["Top"] = "" + (Top + 250) + "px";
BtnImg_AddToCart.Style["Left"] = "" + Left + "px";
Form1.Controls.Add(BtnImg_AddToCart);


return img;

}

that was in the class.


and this is in the code behind aspx.cs:

for (int i = 0; i < 5;i++ )
{
pi1 = new ProductIntroduction(Width, Top, Left, Height, num);
img=pi1.Introduction(p1, img, dl, DataList1, myDS, form1, SqlDataSource2);

Top = Top + 450;



num++;
}


oh and there is another problem - if I add the event method in the class (not in the cs) there is now session using possibility there right?

I hope and will be grateful if you can help me))
Oct 25 '07 #15

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

Similar topics

3
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL)...
2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
3
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which...
0
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. ...
1
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the...
4
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the...
1
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url ...
2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
3
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the...
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.