I try to replace the word "PROCENT" to "%" in an ASP file.
But I got error:
Error "800a01b6'
Object doesn't support this property or method
<%# language="javascript"%>
<%
var newSpanPosBeschreibung = Request.QueryString("newSpan");
if(newSpanPosBeschreibung.indexOf("PROCENT") >= 0 ){
newSpanPosBeschreibung = newSpanPosBeschreibung.replace(/PROCENT/g, "%");
}
//then save the [newSpanPosBeschreibung] into Databank.
%>
How to replace the "PROCENT" to "%"? Thx!
What if you cast the variable to a string first?
var newSpanPosBeschreibung = String(Request.QueryString("newSpan"));
Related
I have 2 aspx pages that uses the same aspx.cs file using CodeFile
I have on one aspx page but not on the other aspx page.
On runtime I want to check if the Literal exist then set the value if it doesn't do nothing.
Did you try using FindControl method?
Literal l = FindControl("control id");
if(l != null)
{
//do your processing
}
I am converting a project from asp to aspx.I am just converting the pages from asp to aspx and fixing the errors(as mentioned in http://msdn.microsoft.com/en-us/library/ms973813.aspx) since my client doesn't want me to convert the whole thing.
I have got a file x.asp which is included in login .asp
This is my orginal code(x.asp)
function AddX( DX, Parent, Name, Value )
Set AddX = AddXEx( DX, Parent, Name, Value, "" )
End Function
function AddXEx( DX, Parent, Name, Value, Namespace )
dim obj
set obj = DX.create( 1, LCase(Name), Namespace)
if Len(Value) <> 0 then
obj.text = Trim(Value)
end if
Parent.appendChild obj
set AddXEx = obj
End Function
%>
I have removed set and added script language = "vbscript" runat = "server" And this is the code after I made the changes(x.aspx)
function AddX( DX, Parent, Name, Value )
AddX = AddXEx( DX, Parent, Name, Value, "" )
End Function
function AddXEx( DX, Parent, Name, Value, Namespace )
dim obj
obj = DX.create( 1, LCase(Name), Namespace)
if Len(Value) <> 0 then
obj.text = Trim(Value)
end if
Parent.appendChild obj
AddXEx = obj
End Function
This is the error I get on compiling
`Compiler Error Message: BC30057: Too many arguments to 'Public Function AddXEx(DX As Object, Parent As Object, Name As Object, Value As Object) As Object'.
Source Error:
AddX = AddXEx( DX, Parent, Name, Value, "" )`
Please tell me how to fix this
Thanks in advance!
You should change your #page directive to Language="VB" and Explicit="True" for ASPX, not VBScript and Option Explicit as this is for classic ASP:
<% #Page Language="VB" Explicit="True" %>
What i'm doing is creating a website where the design is done i html files that are then read into the masterpage using System.IO.StreamReader.
and inside the html templates there are keywords like #USER.LOGIN#
that I replace with functions etc.
The issue is that i'm replacing #USER.LOGIN# With a usercontrol where there is a login form.
I have a function that reads the usercontrol into a string and it works.
but since the usercontrol is loaded to string alle the events are not following.
so when I submit the login form nothing nothing happends (the page posts) but cannot get any of the fields from the form...
NOTE:
i'm using url-rewriting so urls are http://www.domain.com/account/login
where account is account.aspx and login is the mode the account is in.
Code for replacing the keyword in the streamreader loop (pr line)
If InStr(line, "#USER.LOGIN#") Then
line = line.Replace("#USER.LOGIN#", vbCrLf & userfunc.GetMyUserControlHtml("uc", "account_login.ascx", "/account/login/") & vbCrLf)
End If
And the functions to read usercontrol
Public Shared Function GetMyUserControlHtml(contextKey As String, controllerfile As String, Optional ByVal formaction As String = "")
Dim myId As Guid = New Guid()
Return userfunc.RenderUserControl("~\Controllers\" & controllerfile, "", myId, formaction)
End Function
Public Shared Function RenderUserControl2(path As String, Optional ByVal formaction As String = "") As String
Using pageHolder As New Page(), _
viewControl As UserControl = DirectCast(pageHolder.LoadControl(path), UserControl), _
output As New StringWriter(), _
tempForm As New HtmlForm()
If formaction <> "" Then
tempForm.Action = formaction
Else
tempForm.Action = HttpContext.Current.Request.RawUrl
End If
tempForm.Controls.Add(viewControl)
pageHolder.Controls.Add(tempForm)
HttpContext.Current.Server.Execute(pageHolder, output, False)
Dim outputToReturn As String = output.ToString()
Return outputToReturn
End Using
End Function
How would you guyz do this?
I need the userlogin to be hardcoded in the usercontrol but still be able to place it anywhere using the template keyword.
This will also be used with other functions (newsletter signup, shoutbox etc.)
what i would suggest is register you control on the web config..
<add tagPrefix="CustomControl" tagName="LogIn" src="~/UserControls/Login.ascx"/>
you can still use "#USER.LOGIN#" but instead of replacing it with a control...
replace it with a something like this
<CustomControl:LogIn id="LogIn" runat="server"/>
this is just a quick write up.. but you could always try if it works
you can save your HTML like this istead of placing an actual "#USER.LOGIN#"
<% =GetLoginControl() %>
and then create a public function in your code behind named GetLoginControl() and return a response.write of the HTML Mark up you need
I have a aspx page where I build an static url (.shtml) and at the end append it with ?id=1.
when I try to capture this querystring on load it returns null.
if I do same procedure to aspx file it returns the querystring.
<a href="<%#GetSEOUrl(Eval("ID")) %>" ><img
align="left" src="../../App_Themes/default/assets/images/v.png" /></a>
public string GetSEOUrl(object ID)
{
//get url from db which will look like /directory/page.html
structtest valRes = objRes.GetRow(ID);
string r = Request.QueryString["r"];
return Functions.getSiteUrl() + valRes.SEOURL + "?R=" + ;
}
then on my load page i get the querystring :
LinkButton lnk = (LinkButton)this.Master.FindControl("lnkMasterLink");
if (Request.QueryString["r"] != null)
{
lnk.PostBackUrl = "lastpage.aspx";
}
any ideas?
Thanks
va id = Request.QueryString["id"];
keys are case sensitive.
I want to do the following:
<%=var t = ViewData.Model%>
but in VB
<% Dim t = ViewData.Model %>
VB doesn't use a special keyword for implicitly typed variables... just Dim.