|
yesterday i ask you about the webservice and you guide me to this link:
//msdn.microsoft.com/en-us/library/8wbhsy70%28VS.80%29.aspx#Mtps_DropDownFilterText
I do steps but when i run .asmx it has error that i said in my main question.
additionally when i want to open my webservice it has some erorr:
configuring website with asp.net2 failed.you must manually configured this site for asp.net 2 in order for the site to run correctly.
if WSDL has some problem how can i solve it?
|
|
|
|
|
Is it possible to show us what you did to build web service. I think it shouldnt have any problems.
|
|
|
|
|
I send my webservice and my website that use webservice to your email.
I run conver.asmx (it is class in my project)
I thank you that you answer me.
modified on Monday, September 7, 2009 6:14 AM
|
|
|
|
|
You realise that you don't 'run' webservices' as such, although it SHOULD show you an interface if you browse to it. What if you view the source ?
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.
|
|
|
|
|
Im using AJAX to load the HTML from usercontrols through a webservice.
My webmethod returns a string(which is the resulting html from the ascx) and then in javascript i add it to the page. To test, in my usercontrol i have this:
<pre>
<script type="text/javascript">
function meep() {
alert("heeeeelllooooha");
}
</script>
<a href="#" onclick="meep();">Click here</a>
<pre>
Which in my mind should add a javascript function to the page. But when i click the "ClickHere" link it says meep is undefined(i know this thanks to the firefox webdeveloper toolbar)
Thanks
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
If you read about web tech you might come across, anything that implements IHttpHandler , can only handle Requests from the client. ASCX or rather UserControl is not inherited from IHttpHandler , so it cant be called directly from the client. You need to add the user control inside a page (which implements IHttpHandler) and then call the page from the client.
I guess you are using XMLHttpRequest object to make request. When you get the response, you need to place the responseText a div or any container of your wish.
Generally if you set innerHTML you are actually stripping out the <script> elements from the request. So you need to eval Scripts before you place the innerHTML. Rather than doing so, I would recommend to place all the javascript blocks into a javascript file and then from html you call the function.
I think this way your problem will be solved. If you find any more problem, just paste your client side code here to help you.
|
|
|
|
|
Sounds perfectly reasonable. I would prefer to eval them to keep everything in one file(without having to call external js). So how would i go about that? Im using normal asp ajax webmethods with a webservice. And yes im using innerHTML. So what do i need to do just before setting the innerHTML?
Also, if I did decide to have external js files then how would i include those? Because surely when i sent through the <script> tag to include it it would be stripped out too when setting innerHTML?
Thanks alot
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Well,
Just use this :
function sethtml(div,content)
{
var search = content;
var script;
while( script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i))
{
search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);
if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break;
block = search.substr(0, search.indexOf(RegExp.$1));
search = search.substring(block.length + RegExp.$1.length);
var oScript = document.createElement('script');
oScript.text = block;
document.appendChild(oScript);
}
var container = document.getElementById(div);
if(!!container)
{
while(container.firstChild)
container.removeChild(container.firstChild);
container.innerHTML = content;
}
}
Now once you receive the response, instead of directly setting the content to the innerHTML, pass it to this function:
say the id of the div is dvResponse, then
setHtml('dvResponse', ajaxResponse);
The function will find each script blocks using RegEx pattern and add them at the end of the page. If you want the script in head sectionn, just replace the line
document.appendChild(oScript); with document.getElementsByTagName("head").item(0).appendChild(oScript);
roguemat wrote: Also, if I did decide to have external js files then how would i include those? Because surely when i sent through the tag to include it it would be stripped out too when setting innerHTML?
</blockquote>
Yes.. you are right.. In that case you need to add the scripts on the original page where the container div is.
<div class="ForumSig"><font color="red" size="2" face="Verdana">Abhishek Sur
</font><hr><b>My Latest Articles</b><font color="#0000ff" size="1" face="Verdana">
<strong><a href="KB/database/ClrStoredProcedure.aspx">Create CLR objects in SQL Server 2005</a>
<a href="Articles/38695/UnCommon-Csharp-keywords-A-Look.aspx">C# Uncommon Keywords</a>
<a href="KB/miscctrl/Excel_data_access.aspx">Read/Write Excel using OleDB</a><p></p></strong><b><small>Don't forget to click "Good Answer" if you like to.</small></b></font>
|
|
|
|
|
brilliant, works perfectly
One more question if you dont mind. At the moment if i add two of the same control they obviously have the same javascript functions. So when i do a function it will run the wrong one etc. Is it possible to encapsulate these controls like [if they were c#]they were two seperate classes with private methods, but still with access to my main classes(the javascript variables and functions on the asp.page that werent added by any contols) pubic methods.
If not, how would i do it? I messed around with dynamic functions and incrementing an int for each function name but thats plain messy.
Thanks
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Thanks ..
Well.. If you are unsure that the same script may come twice to the page, I think you have to name each script block using ID.
use <script id="srpt">
and before doing appendChild(oScript) just do a call
var scrElem = document.getElementById("yourId");
if(!!scrElem)
document.appendChild(oScript);
Hope you can do it now. Just need to alter the script a bit.
Thanks again for appreciating.. Dont forget to click "Good Answer" if you like my solution.
|
|
|
|
|
Ok I know what you mean but I didnt explain properly.
Lets say i load the same control twice and each one outputs the same javascript:
function doSomething()
{
//something
}
function doSomething()
{
//something
}
And then in each control if i have <a onclick="doSomething">click</a> it wont neceserily run the function that was generated by it.
This is why i was asking about encapsulation, so if each control could only have access to its doSomething function it would always call the right one.
I dont really want to got the route of dynamically making doSomething1(), doSomething2() etc for each control thats added. That seems sily.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
This is really not an issue. Just put it inside a script block and check if its id exists.
Or you can also eval
anchor.click=function()(
//something
}
Creating this automatically from responseText is not easy. You need to create the javascript like this.
|
|
|
|
|
i want my web page to appear like this:a list of references in left side,and when each reference is clicked the corresponding web page to be loaded on the right side(n user should still be able to see the reference menu)..I found out that there is something called frames in html.but it is giving the error as 'frameset' is not supported.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Leave_procedure</title>
</head>
<frameset cols="150,*">
<frame src="default.aspx" name="menu" >
<frame src="registration.aspx" name="main" ></frameset>
</html>
Above is my .aspx page.n is there any alternative to attain my objective???bcoz i found somebody quoting in a site that frames are the product of dark ages 
|
|
|
|
|
myinstincts wrote: bcoz i found somebody quoting in a site that frames are the product of dark ages
Well, that is true. They are other n number of problems while implementing the frames such as propogation of events.
In your case, you can make of use of div/table to do this.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Yes you are right.. We dont use Framesets now...
Reason :
1. It is very hard to handle Javascript Events when there is more than one frame in the document. We have to reference controls from other pages only using window.parent . For example : If you just willing to change the text of a control with some operation of another frame, you need to hook the textbox object in Window.parent object and then get its reference. So we are unnecessarily creating complexity .
2. In Asp.NET we rely with Server side events most of the time. In case of Frames, 2 or more document is created, so if you postback a page, u cant reference the other pages. So we need to forcefully postback other forms to get reference in the server. Also forcing postback of 2 pages simultaneously will create two requests to the server. So you need create custom form element to ensure everything goes in a single postback, which means more complexity .
3. Frames looks very odd and unprofessional to me. Err.. Although, That might be only my problem...
So I would recommend to make layout using Table.
<table style="width:100%;border:0px">
<tr>
<td style="width=30%">
</td>
<td>
<td>
</tr>
</table>
You can create the same page layout easily using table. If you are worried about the splitter control.. you can find a lots of them easily by searching in google. Or you can also create one yourself.
So personally I suggest you to avoid Framesets totally.
|
|
|
|
|
Hi,
I am using datalist to display a Datatable, which contains one text from a multiline textbox,
I found that the multiline mode does not maintains anymore in the datalist, that is to say, the text is diaplayed in one or two every long lines
I want to know what parameter determine the displayed width of one line? I tried several parameters, no any effect.
how to solve this problem? thanks!
modified on Sunday, September 6, 2009 10:11 AM
|
|
|
|
|
|
thanks, actually I have read this two articles before I asked the question here.
I found that my problem is different with those mentioned in the articles.
My prblem is originated from the save of the multiline text into database.
I have checked that if I use 'return' by hand during input text, then the text is correctly saved into database (SQL), but if I do
not use 'return' by hand, then the multiline text becomes automatically one line in the database. By the way, I have used 'Text' format to save the text into SQL datatable.
i.e. now the problem is becoming: how to let SQL tabel knows the input is multiline text.
one strange thing is that: the set width (even small) of DataList control can not display the text into multilines.
|
|
|
|
|
Hello everyone,
I got struck while finding a defense against sql injection.....plz explain how to use regular expression validators on server side so that user is unable to modify source code and inject code.....i found stored procedure a bit of complex so don't wanna use parameterised querries........
|
|
|
|
|
|
greendragons wrote: i found stored procedure a bit of complex so don't wanna use parameterised querries........
Stored procedure and parameterized queries are not same. Parameterized queries are just normal queries with parameters. I don't think there is any complexity involved in using it and it is the obvious method to prevent SQL injection attacks.
|
|
|
|
|
Hey.. Why do you need Regular Expression validators to prevent from SQL injection.... ??
I think it is good to have data validation in the client side... For Example :
"\d+" will only take numeric values...
You may use like
"^(Insert|Update|Delete|Select)([A-Z][a-z]+)+" [It might be better if I take time]
to ensure that the user dont enter DML statements in input.
But why do you need to do this?? I think only a simple thing solves the entire problem. Say you have a TextBox called txtName in the page, you write :
using(SqlCommand cmd = new SqlCommand("Update name = @pName where id='23'",con))
{
SqlParameter param = new SqlParameter("@pName", SqlDbType.NVarchar);
param.value = txtName.Text;
cmd.Parameters.add(param);
cmd.ExecuteNonQuery();
}
Isnt it simple enough???
|
|
|
|
|
I have one question in using validator control in ASP.net:
let's say, I have a validator bound to a textbox, just to check whether the text is empty or not.
I only want the validator checks the textbox when I click some button (such as submit), but I found that the validator also works when I do not click this button. e.g. even I try to redirect to other page, the validator still checks and I can not redirect to other page.
I am wondering, is there any property I can use to handle this problem directly except I use enable and disable functions?
thanks!!
|
|
|
|
|
Seraph_summer wrote: I am wondering, is there any property I can use to handle this problem directly except I use enable and disable functions?
Yes, That is ValidationGroup Property
In your case, Textbox , Submit button and RequiredFiledValidator Should have same ValidationGroup.
For your Referecne :
VAlidation Group[^]
Hope this will help you
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I think you can put the textbox and button in a same validationGroup .
|
|
|
|