|
No, I looked a little deeper into it and you *must* create them in Page_Init if you want their viewstate to be restored properly because the event that loads viewstate into the controls occurs before Page_Load but after Page_Init.
|
|
|
|
|
Are you sure? Has this changed between framework 1.1 and framework 2.0? Otherwise it would be impossible to use dynamic controls in framework 1.1, as there is no Page_Init.
---
b { font-weight: normal; }
|
|
|
|
|
Maybe it's changed, not sure, I never used .net 1.x with asp.net, but that's been my experience with asp.net 2.0 and that's what Microsoft detailed on the page I found at the time when I looked it up on MSDN.
I use dynamic controls for a custom fields section on many of my forms and if I don't create them in page init then I can't retrieve their values later on in the page lifecycle.
|
|
|
|
|
Every postback produces a completely new Page object, so to make a dynamically created control stay on the page, you have to recreate it on every postback.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
When I create a web site I usually create an .aspx and an .aspx.vb file
for each page.
However, I create all my page code in my VB code at runtime.
What I would like to know is:
Is there a development model where the Aspx pages (.aspx files) are
also created at runtime.
If yes could you tell me if should I do it?
Can you give me any advice on creating everything at runtime in my VB
or C# code?
Thanks,
Miguel
|
|
|
|
|
hi!i have a problem for following code.
when i use this code in win-2000 server then there is no prblem
System.Windows.Forms.IDataObject clipboardData = System.Windows.Forms.Clipboard.GetDataObject();
but when try to execute this code in win-server 2003, then follwing exception is throwned
ex = {"Requested Clipboard operation did not succeed."}
please give me solution.
Amit Kuamr Pandey
|
|
|
|
|
I have an image inside a DIV tag.When i click the mouse in a IE browser,at the particular position of mouse click,i need to display the DIV tag's image.
I have captured the coordinates of the mouse click.
HOw to set the X,Y coordinates to the image i have taken inside the DIV tag using javascript.
|
|
|
|
|
You can declare your div for absolute positioning:
div {position: absolute; top: 100px; left: 100px;} and then change its position with something like this:
var e = document.getElementById("myDiv");
e.style.left = 110;
e.style.top = 110;
|
|
|
|
|
Here's a more fleshed-out example:
<html>
<head>
<style>
div.myDiv {font-size: 10pt; font-family: Tahoma;
border: 1px solid #999999;
background-color: yellow;
width: 18px; height: 18px;
position: absolute;
text-align: center;
vertical-align: center;
font-weight: bold;
color: darkBlue;
}
</style>
<script>
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function MoveDiv(x, y)
{
var div = document.getElementById("MyDiv");
div.style.left = x;
div.style.top = y;
}
function MoveToButton(btn)
{
var pos = findPos(btn);
var width = btn.offsetWidth;
var height = btn.offsetHeight;
var x = (width / 2) + pos[0];
var y = (height - 6) + pos[1];
MoveDiv(x,y);
}
</script>
</head>
<body>
<h3>Testing a client-side element move</h3>
<p>Div defined below:</p>
<div id="MyDiv" class="myDiv">
@
</div>
<br /><br />
<hr />
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<br /><br />
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<input type="button" value="Click to move it here"
o n c l i c k = "MoveToButton(this);"
/>
<br /><br /><br /><br />
<a href="#";
o n m o u s e o v e r = "MoveToButton(this);"
>MouseOver move</a>
<a href="#";
o n m o u s e o v e r = "MoveToButton(this);"
>MouseOver move</a>
</body>
</html>
|
|
|
|
|
hello
like i have one aspx/asp page which iam using in my many anither pages so i don't want to write all the stuff every time how can i do this?
i tried with
its not working
and i also tried with
response.writefile("file.aspx")
its working but i want to use some functions of file.aspx page in my present page -----------its throwing an error there because it adds the file at run time and the function in it has not declared before
so how can i do this
can any one suggest me ------------
|
|
|
|
|
Hi,
I think you must use ASP.NET User Controls (*.ascx)
|
|
|
|
|
hello
like i have one aspx/asp page which iam using in my many anither pages so i don't want to write all the stuff every time how can i do this?
i tried with
its not working
and i also tried with
response.writefile("file.aspx")
its working but i want to use some functions of file.aspx page in my present page
|
|
|
|
|
You have to create user controls for that purpose. They are just like your aspx pages and you can drag and drop to any page you want. The extension for that is ascx.
Best Regards,
Apurva Kaushal
|
|
|
|
|
but i have "response.write" stmts in my page how can it work
any other way?
can any one send me one example?
|
|
|
|
|
It does not matter. What you need to do is first create a ascx page(User control). Same as you create a aspx page and then drag it from solution explorer to you web page(aspx page) and that over. You can get the contents of the control to the page.
Best Regards,
Apurva Kaushal
|
|
|
|
|
thanks alot for a very fsater reply
but still iam getting prob because i have some functions in my first page which are having response.write stmts ok and i want to use these functions in my second page.........iam getting reference error
thanks in advance
|
|
|
|
|
I am not been able to understand your because i dont think there is any relation between your user control and response.write statements. What is the exact error message and you debug the code and see where which part is diaplaying the error.
Best Regards,
Apurva Kaushal
|
|
|
|
|
hai apurva
let me explain what i need exactly
ihave one.aspx page ok in that i have written some functions to display some table of content ok
for example...
in my one.aspx ihave a function like...
function disp(pagesize,query...etc)
(iused record set of adodb here to fech the table from param query passed ok)
response.write("")
(taken loop to display)
response.write(")
and so on.
now i want to use this function in my second.aspx
i think now it is clear
thanksrecods that feched from table |
|
|
|
|
|
If you just want to use that function in multiple pages then what you can so is place that function in a class file and then call it from the pages where ever you want.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Can I implement lostfocus, gotfocus and keypress events in ASP.Net as in VB6.0
Nandini Sharma
|
|
|
|
|
Those events occur in the browser, so you use client script, i.e. Javascript, to handle them. They are named onfocus, onblur and onkeypress.
---
b { font-weight: normal; }
|
|
|
|
|
hi dear
i am trying to calculate the total amount of memory and cpu used while using string and stringbuilder.
i am trying this way ...
calling a method in one button click and writin to response.
Process myprocess=Process.GetCurrentProcess();
string str=null;
for (int i=0;i<=10000;i++)
{
str+="Hello1";
str+="Hello2";
}
Response.Write("using string : "+myprocess.WorkingSet.ToString()+" ");
and calling another method on another button click and writing to response.
Process myprocess=Process.GetCurrentProcess();
StringBuilder str=new StringBuilder();
for (int i=0;i<=10000;i++)
{
str.Append("Hello1");
str.Append("Hello2");
}
Response.Write("using stringbuilder : "+myprocess.WorkingSet.ToString()+" ");
but i am not getting the appropriate answer as it is showing the stringuilder is using much memory then string...
i have calculated the total time using two date time variables initialising them before starting and end of loop and then subtracting and getting the milliseconds of difference in between them. one more thing that i am calling both the functions after restarting the page.
please help out me guys, i need the solution of this problem very urgently!!!!!!!!!!!!!!!!!!!!!!!!1
regards
vishal sharma
Thanks & Regards
Vishal Sharma
vishalsharma556@yahoo.co.in
|
|
|
|
|
Don't do this:
Process myprocess = Process.GetCurrentProcess();
Just replace all of the myprocess lines with Process.GetCurrentProcess() . The data in myprocess doesn't change.
|
|
|
|
|
Hi,
we use PostBackUrl passing values of controls from one page to anther page in encrypted way(FORM)
can i use same method to pass the values of variable in code Behind of page 1 to code Behind of page 2?
any one explain
thanks a lot....
|
|
|
|
|
In your second page, look at using PreviousPage.FindControl() passing it the control ID of the control you want the data from in the first page. You'll have to typecast it to the proper control type to get the data, but this does work. I don't believe that this encrypts the data, but it is not visible in the URL.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|