|
where did i miss it?
i can't see it!
|
|
|
|
|
OOPS!
yeah you are right
I'm such an idiot! lol
Thank you so much!
|
|
|
|
|
you're welcome. lol.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
I would think a hashed password, even of a password only a few characters long, might be considerably longer than 16 bytes? Not sure, but could that be the problem?
Edit: Sorry I think I have put you wrong. I was thinking the hex version of hashes possibly.
modified on Saturday, April 2, 2011 5:13 PM
|
|
|
|
|
hi, the problem is simple. look your sql deeply. there is an error
You sql = SELECT UserId FROM [Users] WHERE ([Email]=@Email AND [Password]=@Password
hope u got the mark.
there is a open bracket be the email which will fail the query result.
Good luck.
|
|
|
|
|
Hi
I have a DetailsView on the page and I have made one of the fields a TemplateField. In the EditItemTemplate and InsertItemTemplate I have a DropdownList that is databound to a table in my Sql Server database. I wanted to add an initial value to the DropdownList namely “- select -” .
I set the AppendDataBoundItems property to true and added the initial value as a ListItem.
Markup of the DropdownList
<asp:DropDownList ID="DropDownList_HP" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_HP"
DataTextField="Hospital" DataValueField="H_ID" SelectedValue='<%# Bind("H_ID") %>' Enabled="True">
<asp:ListItem>- select -</asp:ListItem>
</asp:DropDownList>
I also added a RequiredFieldValidator to ensure that a value is selected.
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDV4" runat="server"
ControlToValidate="DropDownList_HP"
ErrorMessage="Select a referring hospital"
InitialValue="- select -" ValidationGroup="PatientInputGroupDV4" SetFocusOnError="True"></asp:RequiredFieldValidator>
This works fine for new input. The problem is however that the database already has records that were entered through a Windows Application and many of these records has a null value in this field and exceptions are thrown when I tried to open these records and the system tried to set the SelectedValue of the DropdownList.
After some more searching I found this help http://msdn.microsoft.com/en-us/library/ms366709.aspx
So I changed the ListItem in the DropDownList markup to the following:
<asp:DropDownList ID="DropDownList_RefHospDV4" runat="server"
AppendDataBoundItems="True" DataSourceID="SqlDataSource_RefHosp"
DataTextField="HospShort" DataValueField="HospID" SelectedValue='<%# Bind("HospID") %>' Enabled="True">
<asp:ListItem Selected="True" Value="">- select -</asp:ListItem>
</asp:DropDownList>
This now solved the problem of opening a record where the value is null in the database, BUT now the RequiredFieldValidator is not validating anymore to make sure that a databound item is selected for this field and not the initial value “- select -”. So basically now it is not checking anymore to see if valid input has been entered for the DropDownList and it accepts “- select -” thus it acts as if the field is not a required field anymore.
In short what is required is that I want to make sure that the user enters a valid selection in the DropDownList, but it must also cater for old records that do not have this field entered yet so that those old records can be opened in the DetailsView .
Opening Old records (with null in that field):
When these old records are opened in the DetailsView the DropDownlist should show “- select -” when the value in the database is null.
Saving records (old or new records):
When saving the record in Insert mode or Update mode the RequiredFieldValidator should show that a valid input is not selected if the DropDownList is still on “- select -”.
Does anyone have any solutions for me for the problem.
Regards.
Kobus
|
|
|
|
|
Hi Kobus,
I suggest this solution:
use javascript to check ur default value b4 post it to server.
<script type="text/javascript">
var sDropDownList_HP = '<%=DropDownList_HP.ClientID %>';
function validateHospitalDropDownList()
{
var ddlHP = document.getElementById(sDropDownList_HP);
if(ddlHp.selectedIndex<1){
return false;
}
else{
return true;
}
}
</script>
In your asp code: there may be some button click event to post back to server:
I assume u have that button,
<asp:Button ID="Button1" runat="server" OnClientClick="if(!validateHospitalDropDownList())return false;" Text="Submit" />
then add attribute OnClientClick and assign JS function to it, if this function return true, the form will post back
normally, else no post back will occur. you can also add some code to show error msg in the JS function.
Hint: in Data Null case, u can use ISNULL('value that can be null', 'new replace value'); function from SQL.
Hope that works!
|
|
|
|
|
Hi mates,
I have a program in asp.net which will print a report viewer to the default printer. When the user
clicked the print button. It will automatically print to default printer. I'm using the System.Drawing.Printing.PrinterSettings for getting the default printer.
Here's the snippet code:
Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Try
Dim rptViewer As ReportViewer
rptViewer = New ReportViewer
With rptViewer.LocalReport
.DataSources.Clear()
.ReportPath = Server.MapPath("rptCert.rdlc") '(IM USING RDLC INSTEAD OF CR)
.DataSources.Add(dataSource)
.Refresh()
End With
myRPT= New CustPrint
With myRPT
.Export(rptViewer.LocalReport)
.m_currentPageIndex = 0
.Print()
End With
Catch ex As Exception
log.Debug(ex.ToString)
End Try
End Sub
----CLASS-----
Public Class CustPrint
' Implements IDisposable
Public m_currentPageIndex As Integer
Public m_streams As IList(Of Stream)
Public stName As String
'create steam
Public Function CreateStream(ByVal name As String, ByVal fileNameExtension As String, _
ByVal encoding As Encoding, ByVal mimeType As String, ByVal willSeek As Boolean) As Stream
Dim stream As Stream = New FileStream("C:\" + name + "." + fileNameExtension, FileMode.Create)
m_streams.Add(stream)
Return stream
End Function
'Export
Public Sub Export(ByVal report As LocalReport)
Try
Dim deviceInfo As String = _
"<DeviceInfo>" + _
" <OutputFormat>EMF</OutputFormat>" + _
" <PageWidth>8.5in</PageWidth>" + _
" <PageHeight>11in</PageHeight>" + _
" <MarginTop>0.25in</MarginTop>" + _
" <MarginLeft>0.25in</MarginLeft>" + _
" <MarginRight>0.25in</MarginRight>" + _
" <MarginBottom>0.25in</MarginBottom>" + _
"</DeviceInfo>"
Dim warnings() As Warning = Nothing
m_streams = New List(Of Stream)()
report.Render("Image", deviceInfo, AddressOf CreateStream, warnings)
Dim stream As Stream
For Each stream In m_streams
stream.Position = 0
Next
Catch ex As Exception
Dim inner As Exception = ex.InnerException
While Not (inner Is Nothing)
'MsgBox(inner.Message)
inner = inner.InnerException
End While
End Try
End Sub
'metafile
Public Sub PrintPage(ByVal sender As Object, _
ByVal ev As PrintPageEventArgs)
Dim pageImage As New Metafile(m_streams(m_currentPageIndex))
ev.Graphics.DrawImage(pageImage, ev.PageBounds)
m_currentPageIndex += 1
ev.HasMorePages = (m_currentPageIndex < m_streams.Count)
End Sub
'print
Public Sub Print()
Dim printerName As String = DefaultPrinterName()
If m_streams Is Nothing Or m_streams.Count = 0 Then
Return
End If
Dim printDoc As New PrintDocument()
printDoc.PrinterSettings.PrinterName = printerName
If Not printDoc.PrinterSettings.IsValid Then
Dim msg As String = String.Format("Can't find printer ""{0}"".", printerName)
'Console.WriteLine(msg)
Return
End If
AddHandler printDoc.PrintPage, AddressOf PrintPage
printDoc.Print()
If Not (m_streams Is Nothing) Then
Dim stream As Stream
For Each stream In m_streams
stream.Close()
Next
m_streams = Nothing
End If
End Sub
----FUNCTION ------
Public Function DefaultPrinterName() As String
Dim oPS As New System.Drawing.Printing.PrinterSettings
Try
DefaultPrinterName = oPS.PrinterName
Catch ex As System.Exception
DefaultPrinterName = ""
Finally
oPS = Nothing
End Try
End Function
Unfortunately, this code will work only in the server, instead to the client computer.
I want a solution/way/approach on how to get the client printer? I want to print an rdlc report at any client not only on the server.
Thank you in advance.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
That isn't how asp.net works. As you have discovered code-behind runs on the server not the client. The only way to use a client resouce such as a printer is to use ActiveX which is troublesome at best.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i've searched on google with ActiveX and i found a code which will get the printers of server or client which is good.like this
<br />
var server="10.1.254.222"; 'change to client ip<br />
var shell = new ActiveXObject("wscript.shell");<br />
var result = shell.Exec("net view \\\\" + server).StdOut.ReadAll();<br />
var line = new Array();<br />
... and so on.
but the problem of the above code will get the list of printers which are shared.
C# コードMicrosoft End User
2000-2008
「「「「「「「「「「「「「「「「「「「「「「「「「「「「
The best things in life are free
」」」」」」」」」」」」」」」」」」」」」」」」」」」」
|
|
|
|
|
It is generalyy a bad idea to use ActiveX control, they are difficult, cumbersome and prone to security issues. Users can disable them and admins can restritct them. They are also only usable in IE. Make the report available and let the use choose which printer.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi
I Was try to get value for label by JavaScript but I got Problem with reading the value it's NULL
|
|
|
|
|
you must be more explicit with your request.
what are you trying to do and what code are you writing,
where is the Label, in master page or in the page, from where are you calling it???
|
|
|
|
|
this is my code
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><br />
<script type="text/javascript" src="js/timer.js"></script><br />
<script type="text/javascript"><br />
window.onload = WindowLoad;<br />
function WindowLoad(event) {<br />
<br />
ActivateCountDown("CountDownPanel1", document.getElementById('lbltime').value, "CountDownEnded1");<br />
<br />
}<br />
<br />
function CountDownEnded1() {<br />
alert("Time End");<br />
location.reload(true);<br />
}<br />
<br />
</script><br />
<asp:Label ID="lbltime" runat="server" Visible="false"></asp:Label>
I Want to get the text in "lbltime" to my code
|
|
|
|
|
ok, if you notice, you are asking for the value of the Label(lbltime) but it has not a text property which will be the equivalent of "Value".
So what you have to do is something like:
<br />
<asp:Label ID="lbltime" runat="server" Visible="false" Text="sometext"></asp:Label><br />
or if you are assigning a value (Text) from the server side, you must do it before the form call for the javascritp code, in Page_Prerender event.
|
|
|
|
|
El_Programmer wrote: if you are assigning a value (Text) from the server side, you must do it before the form call for the javascritp code, in Page_Prerender event.
What?
You are not even close to what the problem is. JavaScript object do have a Value property.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i mean if you want to assign any text to your label(lbltime) from the server side, in Page_Load or Page_Prerender.
because when you call your javascript code your label has no text, that is why you are getting and NULL value.
did you get it?
|
|
|
|
|
That is not why the OP is getting a NULL. Read below. Did you get it?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
ASP.NET adds some name mangling to control ids when they are rendered. The controls are prefixed with the container name such as: Content1_lbltime. Since you are looking specifically for an element with the id lbltime this obviously won't work.
I would strong suggest you use JQuery and something like this
var value = $("id[$='lbltime']").val();
This says to get the element with an id that ends with 'lbltime' and retrieve its value. This will find the control no matter what prefix has been added
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
This code it's work okay in the page with out Masterpage
so the problem is document.getElementById("lbltime").value not work with masterpage
I want code work with masterpage
|
|
|
|
|
Member 7765904 wrote: the problem is document.getElementById("lbltime").value not work with masterpage
That is exactly what I'm saying. Have you tried it? What are you having difficulties with? What don't you understand?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
I suggest this solution, it works for me.
in your JS add variable, and assign the ClientID of ur label control.
<script type="text/javascript">
var slbltime = '<%=lbltime.ClientID%>'
window.onload = WindowLoad;
function WindowLoad(event) {
ActivateCountDown("CountDownPanel1", document.getElementById(slbltime).value, "CountDownEnded1");
}
</script>
bcoz when .Net render asp control to html control, they need to give id to it.
if u use asp:label control, the id will transform into 'Master_ct00_lbltime' something like that.
as far as i know, what other member want to say is if u assign value into ur label control from code behind file(.aspx.cs)
u need to do b4 PreRender state of page life cycle.
PreRender is the state b4 the asp:control are actually transform into html control to send it to the web browser.
Hope it works!
|
|
|
|
|
Look at the source code of the webpage when it comes up. The ID of the label is not what you think it is...because of the MasterPage.
|
|
|
|
|
Let me begin by saying I am not fluent in regex. I need a regex that will validate a date AND time value, not just date and not just time...both. I found a regex written by Bernat Sales at regexlib.com that will validate a date AND time entry, however, it only validates it in European formate (dd/mm/yyyy hh:mm:ss). I need it to validate only in American format (mm/dd/yyyy hh:ss:mm). Can someone, out of the goodness of their heart, please modify this regex to accomplish my goal of validating in American format. Here is Bernat's creation from which you can start:
^((((([0-1]?\d)|(2[0-8]))\/((0?\d)|(1[0-2])))|(29\/((0?[1,3-9])|(1[0-2])))|(30\/((0?[1,3-9])|(1[0-2])))|(31\/((0?[13578])|(1[0-2]))))\/((19\d{2})|([2-9]\d{3}))|(29\/0?2\/(((([2468][048])|([3579][26]))00)|(((19)|([2-9]\d))(([2468]0)|([02468][48])|([13579][26]))))))\s(([01]?\d)|(2[0-3]))(:[0-5]?\d){2}$
Again, I am not a regex guru, nor do I plan to be. I just need this regex for a current page I'm writing. Thanks in advance.
|
|
|
|
|