|
Have you looked at the URL at all ?
garfield185 wrote: onclick="Download(txtFile.text)" />
This quite obviously does not work. You need to get the client side id of the control, then use document.getElementById to look up the control, then get it's actual text. You can use the alert function to debug your code, if you do that now, you'll find that it's null, which is why you're getting the result you are.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
OK, I have no idea what you are talking about... Sorry!!! Could you please write a clue?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
txtFile.Text is not valid javascript. So, it's not working. On the server side, you can get the client side id of your control ( which is not even called txtFile, from what you posted ), and then you can use document.getElementById(clientId) ( where clientId contains that id you got from the server ), to get a reference to the actual control. Then you can get the text of the control ( I think .value is what you want, it's sure not .text ).
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Do you know any web page with an example of all this you are writing?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
Well, if I were to google getElementById, I know I'd easily find that part of it. As for the rest, just use RegisterClientScript to emit javascript from the server that creates a variable which contains the client side id of your textbox, using the ClientID property.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
just:
<pre>
onclick="Download(document.getElementById('txtFile').value)"
</pre>
|
|
|
|
|
|
I think you'll find that this is utterly wrong.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yes. I know so I have deleted that post after posting it.
Thanks
please don't forget to vote on the post that helped you.
|
|
|
|
|
garfield185 wrote:
Why dont you pass :
onclick = "javascript:Download(document.getElementById('<%=txtFile.ClientId%>').value);"
I hope this would work perfectly. If not let me know.
|
|
|
|
|
YOU ARE THE BEST!!!!
It works perfectly, thanks a lot!!!
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
you are most welcome my friend..
Cheers.
|
|
|
|
|
Interesting, when I've tried to do that directly, it's not done the translation to emit the client id, it's appeared in my javascript verbatim. That's why I advocate storing the client side id in a variable.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yes... Its the same thing.
I dont know why he didnt understand.
|
|
|
|
|
Well, your solution was so simple that you could give him one line of code. I do tend not to give code, because it makes people think and understand, but in this case, my experience made me feel that may not actually work. Perhaps I've just done it in a specific context where it wouldn't process the server tags ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Might be. Can you show me where it is not working.
I think there must be problem of mixing up server tags within server side controls.
For example If you write :
<asp:TextBox ID="txt" Text="<%= this.somevariable %>" runat="server" />
You will actually end up with a textbox which has value
<%=this.somevariable%>
rather than the value of the variable.
on the other hand if you write :
<input type="text" id="txt" value="<%= this.somevariable %>" />
It will properly show the value of the variable in the textbox.
In your case this might be the issue.
|
|
|
|
|
Hey.
I am working on application in which I want to create dynamic controls and retrives them in html string.
for example.
public string CreateControl()
{
HtmlTable hTable = new HtmlTable();
hTable.CellPadding = 2;
hTable.CellSpacing = 2;
hTable.Width = "100%";
HtmlTableRow hRow = new HtmlTableRow();
HtmlTableCell hCell = new HtmlTableCell();
hCell.InnerText = "Username";
hRow.Cells.Add(hCell);
hTable.Rows.Add(hRow);
// Now here I want to return created controls in html string.
}
It should be like this
<table CellPadding=2 CellSpacing = 2 Width=100><tr><td>Username</td></tr></table>
Thanks
Imrankhan
please don't forget to vote on the post that helped you.
|
|
|
|
|
Your best bet to do that, is to use a string builder to generate the HTML yourself.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: Your best bet to do that, is to use a string builder to generate the HTML yourself.
I have to write all controls in HTML and I dont want to write inlinne code at server side. I know It is possible because I had done it before one year ago when I worked on custom control but now I forget it.
regard
Imrankhan
please don't forget to vote on the post that helped you.
|
|
|
|
|
You're right, 5 seconds with google got me this:
public string RenderControl(Control ctrl)
{
StringBuilder sb = new StringBuilder();
StringWriter tw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctrl.RenderControl(hw);
return sb.ToString();
}
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Thanks Christian.
please don't forget to vote on the post that helped you.
|
|
|
|
|
Imran Khan Pathan wrote: please don't forget to vote on the post that helped you.
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
ROTFL - yes, that is quite ironic.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
sashidhar wrote: LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
I tried to give him 5 vote but it did't work. when I click on button to vote, it goes to continuous process then I have to refresh page again. I am not able to vote any post here.
please don't forget to vote on the post that helped you.
|
|
|
|
|
Imran Khan Pathan wrote: hCell.InnerText = "Username";
hRow.Cells.Add(hCell);
hTable.Rows.Add(hRow);
// Now here I want to return created controls in html string.
Now use the following to get the string :
StringBuilder sb = new StringBuilder();
StringWriter tw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(tw);
hTable.RenderControl(tw);
string renderedoutput = sb.ToString();
Now find the control string from the object, inspect renderedoutput .
|
|
|
|